I'm trying to write a calculator that gets its input by parsing a single line expression that includes numbers and their operators, like 1+2-3
The number and operator will both be stored in a class derived from the abstract class Token, one called Number and the other Operator. How do I make a stack hold a Token when Token is abstract? I can declare a Token stack[SIZE]; but what will the push and pop functions look like?
Code:const int SIZE=10; class stack { int head; Token stk[SIZE]; public: //init etc void push(Token* var) //doesn't work! {stk[++head] = *var;} Token* pop() {return stk[head--];} };