Class menu

Is it possible to make a menu program by using class?
This was my original code(below) but I want to use class to modify the program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
    system("CLS"); //Flush the stream
    int loop = 1;
    int choice;
    string getinput;
    bool done = false;

    while (loop ==1)
    {
        system("CLS"); //Flush the stream
        cout << "--Menu--" << endl << endl;
        cout << "1. Cube" << endl;
        cout << "2. Rectengular Prism" << endl;
        cout << "3. Sphere" << endl;
        cout << "4. Cylinder" << endl;
        cout << "5. Cone" << endl;
        cout << "6. Quit" << endl;  // menu
    cin >> choice;
rt


Rest of the code: http://pastebin.com/e90dR3fD

I'd appreciate it if someone would give me a link/examples of class menu, if it exists..

P.S Do I need about 6 different classes for this program?

P.S Do I need about 6 different classes for this program?


well, you should, since all those methods could be long(cube,rectangle,sphere), and then inherit those classes in the menu.cpp file.

or you can create one class file with the menu and all those methods.

But the first one is much cleaner.
will i still be able to switch/case??
if done correctly, you wouldn't need a switch / case

you would pass the "switch" to the class you want and it would know what to do
Topic archived. No new replies allowed.