I am trying to make a binary tree. I have a node with a field for data, yes and no. The problem I am having is that I need the yes and the no to point to a different node but I do not believe it is doing that. In insert, "1" means yes. To give you a little better understanding of what I am doing the root node has a data field which will have tail in it. The yes pointer should point to a node with dog in it and the no field will point to a node for an animal without a tail. Thanks in advance!
template <class T>
void BinaryTree<T>::insert(TreeNode *&nodePtr, TreeNode *&newNode, T side)
{
if (nodePtr == NULL)
nodePtr = newNode; // Insert the node.
else if (side == "1")
insert(nodePtr->yes, newNode, in); // Search the yes branch
else
insert(nodePtr->no, newNode, in); // Search the no branch
}
template <class T>
void BinaryTree<T>::insertNode(T num, T s)
{
TreeNode *newNode; // Pointer to a new node.
// Create a new node and store num in it.
newNode = new TreeNode;
newNode->value = num;
newNode->yes = newNode->no = NULL;
side = s;
// Insert the node.
insert(root, newNode, side);
}