i am trying c++, still student in uni, can’t spot where the error comes from. Can someone give some help, please?
class M() {
static bool m() {
cout << "Hello, do you want to tell me your name (y or n)";
char answer = 0;
int times = 1;
while(times < 3) {
cin >> answer;
switch(answer){
case 'y' :
return true;
case 'n' :
return false;
default :
cout << "I am sorry, I don't understand that.";
times += 1;
}
cout << "Your time's up.";
return false;
}
}
}
int main() {
M::m();
};
It’s on this line:
You don’t put brackets after class name definition. Change it to:
There are a few more issues with your code (semi-colon after class closing curly brackets, etc.), the working code would look like so: