what I am trying to do is store same letter to same node. For example: let say I have person, people is sent to be put into a node. This will create two node. I want to some thing like
P: Person People
Person and People are same note
When I run this on Visual Studio I got
C2440 type cast: cannt convert from IntBinaryTree:treeNode to Char;
C2264 std:: basic_string....
void IntBinaryTree::insert(TreeNode *&nodePtr, TreeNode *&newNode)
{
string combineworld;
stringstream sk;
string newsk;
string word = nodePtr->value;
char key = word.at(1);
sk << key;
sk >> newsk;
cout << "newsk : " << key << endl;
if (nodePtr == NULL)
{
nodePtr = newNode;
}
stringstream sk2;
string newsk2;
string word2 = newNode->value;
char key2 = word2.at(1);
sk << key2;
sk >> newsk2;
cout << "newsk2 : " << key << endl;
if (newsk == newsk2)
{
combineworld.append(nodePtr, newNode);
}
else if (newNode->value < nodePtr->value)
insert(nodePtr->left, newNode); // Search the left branch
else
insert(nodePtr->right, newNode); // Search the right branch
}
void IntBinaryTree::insertNode(string num)
{
TreeNode *newNode; // Pointer to a new node.
// Create a new node and store num in it.
newNode = new TreeNode;
newNode->value = num;
newNode->left = newNode->right = NULL;
// Insert the node.
insert(root, newNode);
}