Mail Archives: djgpp/1997/11/16/07:05:24
>
>#include <stack>
>#include <_string.h>
>
Correction #1:
'plus' and 'minus' are STL classes, beware of name clashes !
>enum operators { leftparen, plus, minus, times, divide};
>
>String opString(operators theOp)
>{
> switch (theOp) {
> case plus: return " + ";
> case minus: return " - ";
> case times: return " * ";
> case divide: return " / ";
> case leftparen: return " [ ";
> default: return "\0";
> }
>}
>
>void processOp
> (operators theOp, stack<operators> & opStack, String & result)
>{
> // pop stack while operators have higher precedence
> while ((! opStack.empty()) && (theOp < opStack.top()))
> {
> result += opString(opStack.top());
A typo here. should be opStack.pop()
> opString.pop();
> }
> opStack.push(theOp);
>}
>
The corrections above are not related to your problem.
Probably G++ does not support enums as types for
instantiating a container ('aggregation').
I suggest that you use ints instead your enum type. They probably
have better performance and less generated code.
Eyal.
- Raw text -