hello guys, i am in a desperate position atm...i "killed" google search engine trying finding a class token and binary tree combine in order to evaluate a preOrder expression to inOrder expression... i really tried everything ... but not enough i guess ... any help is accepted ;) thanks in advance ^^
yeah i know ... the above code i fegure it out on my own... but what about token and string expressions? how i implemented 2gether?!? I have this task....but as i said i have no idea how to implement.
class input_token {
private:
enum token_type { NUMBER_TOKEN, FUNCTION_TOKEN, VARIABLE_TOKEN, END_TOKEN };
token_type type;
double value; // set when type is NUMBER_TOKEN
string name; // set when type is FUNCTION_TOKEN
public:
// All necessary functions to manipulate the tokens
};
Expression trees are represented using the class expr_tree:
class expr_tree {
private:
expr_tree *left, *right;
input_token token;
public:
expr_tree();
double evaluate(double v);
void print();
expr_tree *read_expr();
};