1: // Filename: MENU_USE.CPP
2: // Purpose: To illustrate the use of the Menu class.
4: #include <iostream>
5: using namespace std;
6: #include "menu.h"
7: #include "twopause.h"
9: int main()
10: {
11: cout << endl;
12: cout << "This program illustrates "
13: << "the use of the Menu class " << endl;
14: cout << endl;
16: Menu m("Main Menu");
17: m.AddOption("Quit");
18: m.AddOption("Get information");
19: m.AddOption("Do something");
20: m.AddOption("Do something else");
22: int menuChoice;
23: do
24: {
25: m.Display();
26: menuChoice = m.Choice();
27: if (menuChoice == -1)
28: {
29: cout << "\nUser is a dunce!!\n\n";
30: return 1;
31: }
32: switch (menuChoice)
33: {
34: case 1: /* Do nothing */; break;
35: case 2: cout << "\nNow getting information ... \n";
36: Pause();
37: break;
38: case 3: cout << "\nNow doing something ... \n";
39: Pause();
40: break;
41: case 4: cout << "\nNow doing something else ... \n";
42: Pause();
43: break;
44: }
45: } while (menuChoice != 1);
47: return 0;
48: }