I have been programming for 2 days i have run in too a problem that i can not solve. It has put my learning on halt for hours. I have an if statement and i am getting an error about an ==. Here is the code so far:
#include <iostream>
#include <string>
usingnamespace std;
int subtraction (int a, int b)
{
int d;
d = a - b;
return d;
}
int addition (int a, int b) //i discovered you can use and b for all the functions
{ //because they do not function together
int s;
s = a + b;
return s;
}
int multiplication (int a, int b)
{
int p;
p = a * b;
return p;
}
int division (int a, int b)
{
int r;
r = a / b;
return r;
}
int main ()
{
//variables
int a;
int b;
string x;
cout << "Lets do math!";
cin.get();
cout << endl << "These are the available operations:";
cout << endl;
cout << endl << "Addition";
cout << endl << "Subtraction";
cout << endl << "Multiplication";
cout << endl << "Division";
cin.get();
cout << endl << endl << "Which operation would you like to use: ";
cin >> x;
if (x == addition)
{
cout << "You have chosen Addition!" << endl;
cout << endl << "First number: ";
cin >> a;
cout << endl << "Second number: ";
cin >> b;
cout << endl << "Sum: " << addition (a,b);
cin.get();
cin.get();
}
elseif (x == subtraction)
{
cout << "You have chosen Subtraction!" << endl;
cout << endl << "First number: ";
cin >> a;
cout << endl << "Second number: ";
cin >> b;
cout << endl << "Difference: " << addition (a,b);
cin.get();
cin.get();
}
return 0;
}
Here is the error: 61 no match for 'operator==' in 'x == addition'