Postfix Evaluation Snag

I've hit a snag in my postfix evaluation. It's a small snag though, because I know the conversion from infix to postfix works (because I'm only adding the evaluation), and I understand that the ".pop()" function is a void function in the stack class.

But, how would I go about using storing the value popped into a variable? Below is the portion of my code giving me errors. It's only two errors, so it isn't that bad.

I know that what I've got isn't correct, so any direction would be fine. Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void postEval (string st)
  {
    char token, opn1, opn2;
    int result;
    stack <char> stk_;
    stringstream output;

    for (unsigned i = 0; i < st.length(); i++)
      {
        token = st[i];
        if (opn(token)) stk_.push(token);
        else if (op(token))
          {
            opn2 << stk_.pop();
            opn1 << stk_.pop();
            result = eval (opn1, token, opn2);
            stk_.push(result);
          }
      }
  }
Topic archived. No new replies allowed.