請看看這段代碼,我會解釋:想回去功能上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的函數嗎? –