I have a struct version, but dont know what needs to be changed in the createexpressiontree function of the class version. i was told it was very similar to the struct version, so I was thinking i could just copy and paste that version into my new version and just change names around to make it work, but am not sure which things in the class tree are equivalent to struct treenode version.


Code:
 

struct treeNode {
    treeNode *leftPtr;     /* pointer to left subtree */
    std::string Op;                     /* integer data value */
    treeNode *rightPtr;    /* pointer to right subtree */
};
typedef struct treeNode TreeNode;
typedef TreeNode * TreeNodePtr;


class arithmetic_expression
{
public:

    int inputRPN(std::string inputString);
    int inputInfix(std::string inputString);
    void printExpressionTree();
    void printRPN();
    void printInfix();
    int evaluate_Expression();

private:

    TreeNodePtr topPtr;
    int char_is_operator(std::string check);
    std::vector<std::string> parse_string(std::string inString);
    void createExpressionTree(std::vector<std::string> expression);
    TreeNodePtr createTreeNode(std::string Op);

    void printTreeAsArithmeticExpression(TreeNodePtr treePtr, int indent);
    void postOrderArithmeticExpressionPrint(TreeNodePtr rootPtr);
    void inOrderArithmeticExpressionPrint(TreeNodePtr rootPtr);
    int evaluateTree(TreeNodePtr rootPtr);
    TreeNodePtr createNewTreeNode(std::string newNodeData);
    std::vector<std::string> Infix2RPN(std::vector<std::string> infix);
    int p(std::string check);

};

//here is the function to create the tree

void arithmetic_expression::createExpressionTree(std::vector<std::string> expression)
{
    std::stack <TreeNodePtr> localStack;
    std::string Op;
    TreeNodePtr ptr;

    for(int i=0; i<expression.size();i++)
    {

        Op = expression[i];

        ptr = createNewTreeNode(Op);

        if(char_is_operator(Op))
        {

            // adding element to right tree
            if (localStack.empty())
            {
                std::cout<< "Invalid expression: tree not created  " << std::endl;
                topPtr = NULL;
                return;
            }
            else
            {
                ptr->rightPtr = localStack.top();
                localStack.pop();
            }

            // adding element to left tree
            if (localStack.empty()) {
                std::cout<< "Invalid expression: tree not created  " << std::endl;
                topPtr = NULL;
                return;
            }
            else
            {
                ptr->leftPtr = localStack.top();
                localStack.pop();
            }

        }
        // pushing element to stack
        localStack.push(ptr);
    }

    if (localStack.empty()) {
        std::cout<< "Invalid expression: tree not created  " << std::endl;
        topPtr = NULL;
    }
    else
    {
        topPtr = localStack.top();
        localStack.pop();
        if (!localStack.empty()) {
            std::cout<< "Invalid expression: tree not created  " << std::endl;
            topPtr = NULL;
        }

    }


}

//and the helper function to make nodes



TreeNodePtr arithmetic_expression::createNewTreeNode(std::string newNodeData)
{

    TreeNodePtr newNodePtr =  new(TreeNode);

    if (newNodePtr != NULL)
    {
        newNodePtr->leftPtr = NULL;
        newNodePtr->Op = newNodeData;
        newNodePtr->rightPtr = NULL;
    }

    return newNodePtr;
}
okay now here is the new version that uses class tree instead of struct treenode

Code:
 

class Tree
{
public:
    Tree(std::string input,Tree *leftSubTree=NULL,Tree *rightSubTree=NULL);
    Tree(const Tree &inTree);   //COPY CONSTRUCTOR
    ~Tree(); //DESTRUCTOR

    int evaluate(std::map< std::string, int > ipMap); //EVALUATE THE EXPRESSION
    void postOrderPrint();
    void inOrderPrint();

private:
    Tree *leftPtr;
    std::string Op;
    Tree *rightPtr;
    int NodeType;

  };


#endif


// another header file i think may need to be used in my tree creating function :

class RPNstring
{
public:
    RPNstring(std::string inString){ expression = inString; };
    std::string getString(){return(expression);}

private:
    std::string expression;
};

class Infixstring
{
public:
    Infixstring(std::string inString){ expression = inString; };
    std::string getString(){return(expression);};
private:
    std::string expression;
};




class arithmetic_expression
{
public:
    arithmetic_expression(RPNstring inString);
    arithmetic_expression(Infixstring inString);
    arithmetic_expression(const arithmetic_expression &inExpression);  //Copy constructor
    ~arithmetic_expression();  //Destructor
    arithmetic_expression & operator=(const arithmetic_expression &inExpression); //assignment operator
    void printRPN();
    void printInfix();
    int evaluate_Expression(std::map< std::string, int > ipmap);



private:
    Tree *tree;  //pointer to root of expression tree

    void createExpressionTree(std::vector<std::string> expression); //create expression tree from RPN expression vector
    std::vector<std::string> parse_string(std::string inString); //supplied helper function to parse string and create expression vector.
    int char_is_operator(std::string check); //supplied helper function

   
};


// And now the function that is supposed to be very close to the struct version but i need help with the conversion :

void arithmetic_expression::createExpressionTree(std::vector<std::string> expression){

}