利用栈实现简单计算器的例子(Calculator)(2) case '-': result = operand1 - operand2; break; case '*': result = operand1 * operand2; break; case '/': if (operand2 == 0) { cerr << "Divided by 0!" << endl; s.ClearStack(); return; } else result = operand1 / operand2; break; } s.Push(result); } //清空操作数栈 void Clear() { s.ClearStack(); }public: //构造函数,建立一空栈 Calculator(void) {} //计算表达式的值 void Run() { char op; double operand; while (1) { cin >> op; if (cin.eof()) return; while (op != '=') {