Во-первых, это код цикла while:
void Menu() {
string option;
char yes;
yes='y';
while (yes == 'y') {
cout << "Commands: buy, sell, directory, and exit: ";
getline (cin, option);
if (option == "buy") {
...
}
...
cout << "Do you wish to continue? Press y for yes, n for no: ";
cin >> yes;
}
}
В этом случае, когда цикл отключается во второй раз (нажмите да), он возвращается к:
cout << "Do you wish to continue? Press y for yes, n for no: ";
Я думаю, что этоимеет некоторое отношение к предоставлению ответа на getline () рано, но я не знаю, где.
IE:
Here is the menu: Commands: buy, sell, directory, and exit: buy
Enter a player's I.D: 2
Here is your current money after purchasing Player X: 150000
Do you wish to continue? Press y for yes, n for no: y
Commands: buy, sell, directory, and exit: Do you wish to continue? Press y for yes, n for no: y
Commands: buy, sell, directory, and exit: Do you wish to continue? Press y for yes, n for no:
Намерение состоит в том, чтобы повторить цикл при нажатии yes (включаявозможность ввода другой команды).