More on Program Flow 203
7
35: default:
36: cout << “Please select again! “ << endl;
37: break;
38: } // end switch
39:
40: if (exit == true)
41: break;
42: } // end forever
43: return 0;
44: } // end main()
45:
46: int menu()
47: {
48: int choice;
49:
50: cout << “ **** Menu **** “ << endl << endl;
51: cout << “(1) Choice one. “ << endl;
52: cout << “(2) Choice two. “ << endl;
53: cout << “(3) Choice three. “ << endl;
54: cout << “(4) Redisplay menu. “ << endl;
55: cout << “(5) Quit. “ << endl << endl;
56: cout << “: “;
57: cin >> choice;
58: return choice;
59: }
60:
61: void DoTaskOne()
62: {
63: cout << “Task One! “ << endl;
64: }
65:
66: void DoTaskMany(int which)
67: {
68: if (which == 2)
69: cout << “Task Two! “ << endl;
70: else
71: cout << “Task Three! “ << endl;
72: }
**** Menu ****
(1) Choice one.
(2) Choice two.
(3) Choice three.
(4) Redisplay menu.
(5) Quit.
OUTPUT
LISTING7.17 continued