C++ Basic Calculator

Hi, my name is Justin and I'm new to C++ and this forum. I have been following TheNewBoston's tutorial about C++. He showed me how to make a simple calculator. It was very easy to make and it worked fine, but now I'm trying to add something to it. I'm trying to that the user can tell the computer to +, - or * the sum. But it doesn't work for some reason. Here is my code.
Sorry if my English grammar is bad...

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
#include <iostream>
using namespace std;


int main ()
{
    int a;
    int b;
    int c;
    int som;

    cout << "Typ een nummer in\n";
    cin >> a;

    c = +, - , *;
    cout << "Wil je het met iets vermenigvuldigen (*), aftrekken (-) of optellen (+)? typ +, - of *";
    cin >> c;


    cout << "Typ nog een nummer in\n";
    cin >> b;


    som = a c b;

    return 0;

}


I don't know what I did wrong, like I said, I'm new to C++, and I only saw TheNewBoston's tutorial ( http://thenewboston.org/list.php?cat=16 )

Thanks!

Oh and don't mind the Dutch text.
int c; c = +, - , *;
What kind of integer is +,-,* ? And what are you trying to do by making c equal to these things? The very next thing you do is put something else in it anyway - cin >> c;

The comma operator , does not do what you think it does. Don't use it.

som = a c b;
What do you think a c b will do? It's just wrong.
Last edited on
Thanks, but please tell me what I did wrong and how I fix it?
Moshchops has already explained what you have done wrong. First off, an int has to equal a number, and one number only.

And the whole som = a c b; thing won't work at all.

I think that you should go back and practise the language a bit more.
Ok thanks guys! I sure will.
Topic archived. No new replies allowed.