请看看这段代码,我会解释:想回去功能上if/else语句
void GameOver()
{
cout << "\nWelp, you died. Want to try again?" << endl;
cin >> choice;
if (choice == "Yes" || "yes")
{
/*This is where I want the code. I want it to go back to the last
function that the player was on.*/
}
if (choice == "No" || "no")
{
cout << "Are you sure? The game will start over when you open it back up." << endl;
cin >> choice;
if (choice == "No" || "no")
{
cout << "Well, bye now!" << endl;
usleep(1000000);
exit (EXIT_FAILURE);
}
}
return;
}
我想这样,当我在GAMEOVER功能选择“是”,我想要一个if/else
声明说:“如果你来自这个功能,那么你会去那功能”,你明白我在说什么?
例如,假设我在GameOver
函数中,而我来自FightProcess
函数。我选择“是”,那么它会去Town
功能。 我将如何编码?
从'void'你是指一个返回void的函数吗? –