嘿,我正在用 C++ 制作游戏。这是大学的工作,简要说明不使用头文件,游戏必须是基本的。问题是,游戏结束后它仍然要求选择。我试图打破,退出,但仍然没有快乐。程序不会退出。谁能帮我这个?
这是我的代码:主要
int main() // The main function is set to int.
// The return value has to be an integer value.
{
menuText();
while(menu) // Loop to revert back to menu when choice is not compatable with options.
{
int selection;
cout<< "Choice: ";
cin>> selection;
switch(selection)
{
case 1:
cout << "Start Game\n";
playGame();
break;
case 2:
cout << "Exit Game\n";
cout << "Please press enter to exit...\n";
menu = false ;
break;
}
}
system("pause"); // To stop the program from exiting prematurely.
return 0; // this is needed because the main is set to return
// an integer.
}
int playgame()
status Status = {100,20,80,80,20};// declaration of class members.
//Contents of PlayGame().............................
exitGame();
return 0;
}
void exitGame()
{
cout << "\n\nPlease press enter to exit the game.";
return;
}