There are many applications which require the occurrence of the main menu again and again.
The user chooses those options until the user wills to quit the program. In other words the termination of the program is in the hands of the user. Here is an example of a simple menu driven program from an application designed for LESCO.
LESCO L1; // class LESCO
Bool LESCO::ProcessMenu( )
{
cout<<"\t\t\tChoose an Option:\n 1) Login in as a Employee(Press 1) 2) Login as a customer(Press 2)
3) Quit(Press 3) \n\nYour Option:\t";
int option;
cin>>option;
cout<<endl<<endl<<endl;
if(option == 1)
{
// Your code here return
// return false to continue loop and return true to break the loop
}
if(option == 2)
{
// Your code here return
// return false to continue loop and return true to break the loop
}
if(option == 3)
{
return true; // Option 3 is quit option the loop will break and menu will not be shown again
}
}
int main()
{
while(L1.ProcessMenu()=0)
{
}
}