我得到expected primary-expression before "else"
第一个 else 的错误,我不明白为什么。我对所有支撑进行了三次检查。
if(Owin = win)
{
cout << "The computer has defeated you!\n\n";
cout << "Would you like to play again? (Y or N) : ";
cin >> restart;
if(restart == 'Y' || restart == 'y');
{
cout << "\n\n\n";
main() ;
}
else
{
cout << "Good Bye!\n\n";
system("pause");
return(0);
}
}
else
{
}
最佳答案
if(restart == 'Y' || restart == 'y');
删除那里的分号以修复错误。这个 ;
结束了 if
语句,这意味着 else
实际上不是任何 if
语句的一部分,因此错误。
关于c++ - "else"错误之前的预期主表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13945190/