Program goal: user input for 2 equations to evaluate the operator signs. i.e. 1 * 2 + 4 - 4
and 5 - 2 * 6 + 9 would be the same --> " * + - " in both, order does not matter.
Output: cout saying match or not match.
I'm not sure how to go about checking the operators in the best/easiest fashion, in the main(), or in my cpp file where 90% of the "work" is happening. I've tried all "i" know to do. Obviously I'm missing something, and/or went about this program totally abstract. But, I am basically teaching myself and slightly struggling. So.. he's the code: ( any help is GREATLY appreciated !)
void stack::push(int a,int b) { //why mixing the types?
//An enum in your class would be a lot better that this constants
//(that are not const) repeating all over the code
char p ='+',
s= '-',
m = '*',
d = '/',
e = '=';
char pp ='+', //why repeat the info?
ss = '-',
mm = '*',
dd = '/',
ee = '=';
//a switch will be clearer
if(a == p){
cout << p;
p++; //eh? That local variable will die when the method ends
//...
}
Your push method does not modify your object. That doesn't make sense. And why is it recieving 2 parameters?
There is no need for you to call the destructors (in fact, can be dangerous) char ch1=NULL; it is not a pointer, use '\0' or 0. (the result is the same)