/* * ***************************************************************************** * file name : Postfix_Evaluator.h * author : Hung Ngo * description: interface to the Postfix_Evaluator class * ***************************************************************************** */ #ifndef _POSTFIX_EVALUATOR_H #define _POSTFIX_EVALUATOR_H #include #include "Lexer.h" class Postfix_Evaluator { public: // constructors Postfix_Evaluator(Lexer lxer=Lexer("")) : lexer(lxer), operand_stack() {} // evaluate the expression void set_expression(Lexer); double eval(); private: // given an operator op, and two operands a and b, return (a op b) double eval_op(char, double, double); Lexer lexer; std::stack operand_stack; }; #endif