Moving between menus without recursion and other evil spirits
The problem is this: there is a class in which the program menu is implemented. At some point, you need to switch to another method (submenu). I implemented it like this (code snippet from the method.void MainMenu()):
switch (user_choice_)
{
case ADDNUMBERMENU:
AddNumberMenu();
break;
Further, already in this menu, I implemented what I needed:
// Menu for creating a new instance
// class of a number in the system of residual classes
void Menu::AddNumberMenu()
{
while (true)
{
system("cls");
cout << "You have selected the number creation menu.\n"
<< "Select input option:\n"
<< "1) Create and init in decimal\n"
<< "2) Create and init in mod system\n";
cin >> this->user_choice_;
if (this->user_choice_ < 3 && this->user_choice_ > 0)
{
break;
}
}
}
And now the actual problem. How to return from ** AddNumberMenu () ** method to ** MainMenu () ** method without recursion and invoking the devil. The first thing that comes to mind is recursion. But when creating a menu class, the user_choice_ field is initialized and in general this is a collective farm.