我正在尝试 c++,仍然是大学的学生,无法发现错误来自哪里。有人可以帮忙吗?
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();
};