Program wont compile because of a:
Comparison between pointer and integer
Can this program be saved? Is it badly written? I'm only new, so any help's much appreciated.
( I should probably comment my code - But, sometimes I comment not enough, sometimes I comment too much. On larger programs I comment, but on smaller ones, I think when left un-commented, they look nicer )
Code:
class operate{
public:
char oper;
int w;
int x;
int recognize(char opr, int y, int z);
int add(int y, int z);
int multiply(int y, int z);
int divide(int y, int z);
};
int operate::add(int y, int z){
return y + z;
}
int operate::multiply(int y, int z){
return y * z;
}
int operate::divide(int y, int z){
return y / z;
}
int operate::recognize(char opr, int y, int z){
if ( opr == "+" ){
return add(y,z);
}
else if (opr == "*" ){
return multiply(y,z);
}
else if (opr == "/" ){
return divide(y,z);
}
else {
return 0;
}
}
int main(){
try {
operate calculator;
cout << ">>>";
cin >> calculator.w;
cout << ">>>";
cin >> calculator.oper;
cout << ">>>";
cin >> calculator.x;
cout << calculator.recognize(calculator.oper, calculator.w, calculator.x);
}
catch (...) {
cout << "Default error. " << endl;
}
system("PAUSE");
}