Error with classes

May 5, 2013 at 7:17pm
I have been coding C++ for a few days now, I know the basics + a little more.

But today, while coding a calculator in a way I've never coded it before, I got an error.

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>

using namespace std;

int main();

class Menu{
    public:
        void Start(){
            cout << "Welcome to the calculator!\n" << endl;
            cout << "What would you like to calculate with? Addition (1), subtraction (2),\nmultiplication (3) or division (4)" << endl;
            cin >> answer;
            if(answer == 1){
                cout << "You chose addition!" << endl;
                Addition additionObject;
                additionObject.beginCount();
            }
            else if(answer == 2){
                cout << "You chose subtraction!" << endl;
                Subtraction subtractionObject;
                subtractionObject.beginCount();
            }
            else if(answer == 3){
                cout << "You chose multiplication!" << endl;
                Multiplication multiplicationObject;
                multiplicationObject.beginCount();
            }
            else if(answer == 4){
                cout << "You chose division!" << endl;
                Division divisionObject;
                divisionObject.beginCount();
            }
            else{
                cout << "I do not understand, try again!\n\n";
                main();
            }
        }
    private:
        int answer;
};

class Addition{
    public:
        void beginCount(){

        }

};

class Subtraction{
    public:
        void beginCount(){

        }
};

class Multiplication{
    public:
        void beginCount(){

        }
};

class Division{
    public:
        void beginCount(){

        }
};

int main()
{
    Menu menuObject;
    menuObject.Start();
    return 0;
}


There was a total of 12 errors. I cannot understand what's wrong.

The error thing: http://i.imgur.com/3daM2h8.png
May 5, 2013 at 7:30pm
Try including the class declarations before the class menu. I didn't have time to test it, but it might work.
May 7, 2013 at 8:05pm
What do you mean?
May 7, 2013 at 8:08pm
Why is there a main proto and you never made functions for adding ect so maybe that's why but it looks ok to me oh and hemeans put the main class under the others and remove the main call on line 35
Last edited on May 7, 2013 at 8:14pm
May 7, 2013 at 8:12pm
Put the lines 42-69 (the declaration of Addition, Subtraction etc.) before the declaration of class Menu.
And just never call main();
Topic archived. No new replies allowed.