Question: Complete the implementation of function postfixTest(), which use an integer stack to evaluate post-fix expressions. For simplicity, you can assume the post-fix expression is input
Complete the implementation of function postfixTest(), which use an integer stack to evaluate post-fix expressions. For simplicity, you can assume the post-fix expression is input character by character (i.e., not an entire string), and each operand is a non-negative, single-digit integer (i.e., 0,1,,9).
However, you are supposed to detect invalid/ illegal post-fix expression input, e.g., 4 5 + -
void postfixTest() { myStack operandStack(100); cout << "Please enter the operands (integers 1~9) and operators (+, -, *, /) one by one..." << endl; cout << "and enter '=' to indicate the end of the expression and to output the result." << endl; while(1){ char inputHolder; cin >> inputHolder; // TODO
} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
