You need to go back to basics
but the below seems to work:
#include <iostream>
using namespace std;
class test
{
public:
bool t()
{
cout << "enter your answer(y or n)\n";
char answer;
cin >> answer;
if ( answer == 'y' ) return true;
else return false;
}
};
int main ( void )
{
test foo;
cout << foo.t();
cin.get();
cin.get();
}
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
You'd think someone with over 200 posts would have figured out either to use code tags, or turn off smilies.
At least enough to review the post before pressing submit.
What an unreadable mess!
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
>thanks for quick reply, as i said i am a newbie
>now i get the following error when compiling:
Post your entire code
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
I always thought gcc was to compile c code, but don't quote me on that. Also in the code you posted the iostream.h shouldn't have the .h in it.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
What confuses me is that you are doing a cout on a function that you need to interact with... you should split the two into two seperate functions within the class, one being a setBool, the other being a getBool
Manutebecker
Junior Poster in Training
51 posts since May 2008
Reputation Points: 10
Solved Threads: 3