how to use boolean values in classes?
I have a problem in a c++ program when you are using boolean values to return true or false, how does this work in classes?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include<iostream>
#include<string>
using namespace std;
class BoolLearn
{
public:
bool testingBool(string);
};
bool BoolLearn::testingBool(string strng)
{
if(strng.length()!=10)
{
return false;
}
else return true;
}
int main(int argc, char *argv[])
{
char *ch=argv[1];
BoolLearn test;
ifstream file;
ofstream out;
if (argc>1)
{
file.open(argv[1], ios::in);
if (file.is_open())
{
string strng;
inputfile>>strng;
while(!file.eof() && !file.fail())
{
string temp;
getline(file,temp);
calculate.append(temp);
}
test.testBool(strng);
if(true)
{
cout<<"has 10 characters";
}
if (false)
{
cout<<"fail";
}
}
}
|
Like so:
1 2 3 4 5 6 7 8
|
if(test.testBool(strng))
{
cout<<"has 10 characters";
}
else
{
cout<<"fail";
}
|
Thank you!!!!
Topic archived. No new replies allowed.