I'm having a headache trying to build an expression tree, in particular the pointers for the treenodes, which i have no clue on how to implement and actually create the nodes to store data which is supposed to be pretty basic but the code just confuses me.

For example, when i want to create an expression of 5 + 5 this is what it should look like:

```
  +
 / \
5   5

```

However when implementing this, i'm not sure how to begin. How do i get the operator in the root node and the numbers as children? I know i can store them in a stack and read off the top however the set parent, left child and right child methods only take (TreeNode \*) arguments while the vector tokens are type string. 

Also the constructor for the TreeNode take an integer and operator value, why is that? How can i get those values into their respective nodes as root, parent and children?

```
ExprTree.cpp

    #include "ExprTree.h"
    #include <sstream>
    #include <iostream>

    TreeNode * createOperatorNode(const string & op){

      if (op == "+") return new TreeNode(Plus);
      if (op == "-") return new TreeNode(Minus);
      if (op == "*") return new TreeNode(Times);
      if (op == "/") return new TreeNode(Divide);
      return new TreeNode(NoOp);

    }

    /*
     * Basic constructor that sets up an empty Expr Tree.
     */
    ExprTree::ExprTree(){

        this->root = NULL;
       this-> _size = 0;

    }

    /*
     * Constructor that takes a TreeNode and sets up an ExprTree with that node at the root.
     */
    ExprTree::ExprTree(TreeNode * r){

        this->root = r;
    }

    ExprTree ExprTree::buildTree(vector<string> tokens){ 

// the tokens are the broken up arithimec expression
i.e 
5 
+ 
5
// not sure what to do here, i've tried using stacks but i wasn't sure how to get the stored data into the nodes.

    }

```

TreeNode.cpp

```
#include "TreeNode.h"

TreeNode::TreeNode(Operator o){
  op = o;
  parent = 0;
  leftChild = 0;
  rightChild = 0;
}

TreeNode::TreeNode(int val){
  op = Value;
  value = val;
  parent = 0;
  leftChild = 0;
  rightChild = 0;
}

```

TreeNode.h

```
#include <string>
#include <sstream>

enum Operator {Value, Plus, Minus, Times, Divide, NoOp};

class TreeNode {

 private:

  Operator op; //If this node represents an operator, this is where it's stored.
               //It can take values from the Operator enum (i.e. Plus, Minus, etc.)
               //If it represents a value, use the Value value. :D
  int value; //If this node stores an actual number, this is it.

  TreeNode * parent; //Pointer to the parent.
  TreeNode * leftChild; //Pointer to the left child of this node.
  TreeNode * rightChild; //Pointer to the right child of this node.

 public:

  TreeNode(Operator); //Constructor to use for +, -, * and /.
                      //Example: TreeNode(Plus);
  TreeNode(int); //Constructor to use for actual numbers.
                 //Example: TreeNode(5);
  void setParent(TreeNode *); //Set the parent pointer.
  void setLeftChild(TreeNode *); //Set the left child pointer.
  void setRightChild(TreeNode *); //Set the right child pointer.
  TreeNode * getParent(); //Get the parent pointer.
  TreeNode * getLeftChild(); //Get the left child pointer.
  TreeNode * getRightChild(); //Get the right child pointer.
  int getValue(); //Returns the stored value;
  Operator getOperator(); //Returns the stored operator.
  bool isValue(); //Returns true if this node is a Value node.
  bool isOperator(); //Returns truee if this node is Plus, Minus, Times or Divide node.
  std::string toString(); //Returns a simple string representation of the node.

};

```