Private member elements:
A vector of structs named symbolTable where the struct contains 2 fields: name (type string) and value (type double).
Methods - Implement the following functions:
Implement the makeExpTree function that accepts an exp as a string argument and creates an expTree.
A bool function named readSymbol that accepts a filename (string) as an argument and reads data from a file where each row has two values: a symbol name (string) and a value (double). Function heading:
bool readSymbol(string fname)
Function returns true if the file is opened successfully, false otherwise.
A lookup function that accepts two arguments: string and value as shown below:
bool lookup(string name, double & value)
function finds the value from the symbolTable matching that of the given name. It returns false if the name is not found in the table.
A double function named eval that evaluates the expression tree and assigns the result to the reference argument. This evaluation should handle expressions with a mix of numbers (in string form) and variables whose value can be found in symbolTable. Function heading:
bool eval(double & result);
function returns true if eval is successful, false otherwise. For this assignment, we will assume that the expression is grammatically correct. As such, the only error will be the result of a missing symbol which is identified by the lookup function. A straightforward implementation is to call a recursive version of the eval function that does all the work. It will have the following heading:
bool eval(node<string*> rt, double& result);
Sample I/O
Create an appropriate main function that will test all the new features. For example, the main could first read the data from a file by calling readSymbol. It then continues to ask the user for an infix expression, create an exp tree, and then call eval to evaluate and print the result.
Required Data Structure
You MUST use ExpTree class which derives from the binary tree base class.