Hi there i have a method called
int compare(char op1, char op2)
the method will return 1, -1 or 0 depending on the result of the comparison. (1 if op1 < op2).
I need to compare the following operations:
- subtraction
* multiplication
/ division
^ exponentiation
% remainder
I have considered using an enum such as:
enum ops{
'+'=1, '-'=1, '*'=2, '/'=2, '^', '%'
}var;
but this doesn’t compile. Can anyone lend a hand?
You can’t use characters as keys for the enum, you should do something like: