delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/16/07:05:24

From: eyal DOT ben-david AT aks DOT com
To: cdkrug AT aol DOT com
cc: djgpp AT delorie DOT com
Message-ID: <42256551.00400BFF.00@aks.com>
Date: Sun, 16 Nov 1997 13:58:05 +0200
Subject: Re: Mysterious C++ STL compiler message
Mime-Version: 1.0



>
>#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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019