I am writing a program which converts postfix arithmetic expressions to infix ones using a stack. The user input is a string, which is split into an array (treating spaces as delimiters). Then a case statement for "+", "-", "*" and "/" distinguishes between operators and operands (i.e. if it's not one of those symbols, it's an operand; so typecast to integer).
I was wondering whether it's possible to create something similar to an enum, where the admissible types are either integers, or the symbols +, -, * and /?
Tokenclass that represents whatever you want. Then either subclass it forOperatorTokenandNumberTokenso you can put them all on the same stack, or use something simpler likeisOperator(), where the integer would then have the value ofOPERATOR_PLUS,OPERATOR_MINUS, etc.