I need some help with postfix expression please. I've only been able to find examples about changing from infix to postfix. With the code provided below, I want it to the following:
1. if the token is an operator (it is a +, -, *, or /)
a. two items are popped off the stack
b. the operator is applied to them
c. the result is pushed back onto the stack
2. if the token is an integer (not a +, -, *, or /)
a. it is pushed onto a stack
any help will be appreciated. thanks.
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
string line;
getline(cin, line);
// Create a string stream that will read from "line"
stringstream ss(line,stringstream::in);
// While there are more tokens...
while (!ss.eof())
{
string token;
ss >> token;
//display token for testing
cout << token << endl;
}; //end while
// The should be one and only one item left on the stack
// print the item at the top of the stack
return 0;
}