Thread: pointer help
View Single Post
Old Apr 2nd, 2006, 3:21 PM   #53
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
What do you not get from:
Quote:
parent is the name of the parameter, you should pass in root in the first call to realInsert, as root is the top level parent of the heap.

As to what to pass as parent and newNode. When you first call the realInsert function the parent would be root, from then on when you recurse down, you would use parent->getLeft() or parent->getRight().
Pass in the newNode that was created at the top of insertSpot as the newNode parameter.
That means your call.
realInsert(*ar, i, root, newNode);
While I gave already gave you:
realInsert(ar, i, parent, newNode); // still needs fixing

And did you even check to see what you were copying?
void insertSpot(int option)
{
	heapNode *newNode = new heapNode(option);
	int arrayValue;
	bool isOne = false;
	int ar[32];
	int i = 31;
	counter++;
	if(root == NULL)
	{
	  root = newNode;
	}

	else
	{
		int arrayValue;
		bool isOne = false;
		int ar[32];
		int i = 31;
		int temp = counter;

And lastly, you should remove the comments that say: "//get value", when the function is called "getvalue". Only comment when it makes things more clear.

Just a quick question: how much programming experience do you have?
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote