Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Chimaera

Problems with my HasParent()

This topic is 5560 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here's the problem: I'm writing my own doubly linked list (see here) and I have a boolean function in my CNode class called 'HasParent()'. This is supposed to come in handy during attachments/detachments, when I need to see if the node already has a parent. Seems logical enough, I think. This is how my HasParent() function goes:
	bool HasParent()
	{
		if(pParent != NULL)
			return true;
		else
			return false;

	} // end HasParent
   
The project compiles nicely but crashes upon execution. When I debug I'm pointed to the line "if(pParent != NULL);" This may have to do with one of my Attach, AttachTo, or Detach functions. I was never good at debugging (btw, if anyone could point me to some helpful resources online). If my entire CNode code would be of any help, here is the link again: here). Please, any help you can provide. Thanks in advance. // "Programmers don't byte, they nibble a bit." // chimaera [edited by - chimaera on April 1, 2003 5:12:23 PM] [edited by - chimaera on April 1, 2003 10:10:55 PM]

Share this post


Link to post
Share on other sites
Advertisement
If the problem occurs within an Attach() function, the node you''re passing is a NULL pointer. You can fix this with a line at the beginning of your Attach() function like so:

if (pNewNode == NULL)
return;

If it happens within the Detatch() or AttatchTo() functions, the node is somehow getting deleted before it''s finished.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!