The problem here is that the stack
and vector
contain different types. The stack
contains string
, while the vector
contains Token
. You will need to construct a Token
from a string
as in:
postfix_expr.push_back(Token(stack.top()));
Of course you will need the appropriate constructor implemented in Token
.
Also you shouldn't name your stack
the same as its data type. Name it something like tokenStack
as to avoid conflicts in the variable name and type with the compiler.