• Advertisement

Archived

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

help with a linked list class please

This topic is 5652 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

I need to insert nodes in a sorted order....and for some reason: ....here is the code where Im getting trouble Im getting an acess violation Node * getLink(); //.h Node * Node::getLink() //.cpp { return link; } link is defined as Node * link; in the .h of the node file

Share this post


Link to post
Share on other sites
Advertisement
Why would you post this in the lounge?

That''s not nearly enough information to answer the question; there''s a linked list tutorial here on the site, I believe, and even if there''s not a little searching will uncover one. Its a common enough problem.

PS: ''ASSERT(link);'' before using it

CM

Share this post


Link to post
Share on other sites
That's probably not what's giving you the error. Returning a memory address is completely harmless.

It's what you're trying to DO to that memory address that's giving the error.

What's calling that function when the error occurs?
What happens to that pointer value after it returns?

You need to do a lot better logging if you want to do dynamic memory. Otherwise you're going to spend a lot of time chasing red herrings.

Try using cout<<link->getLink()+0<
You may be trying to write to a NULL pointer. That will show you the address it's returning. The +0 turns it into an int. Probably isn't needed.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting | Tiberian Merchandise!!!! | GameShot ]


[edited by - KalvinB on November 3, 2002 6:20:35 PM]

Share this post


Link to post
Share on other sites
-> this should be in the general programming forum.

Besides that, you need to provide a lot more information about your class structure and code.

Share this post


Link to post
Share on other sites
quote:

This was already here


Right. I didn''t check for doubles before moving. Since this post doesn''t contain any relevant information needed to solve the problem (class structure, member function code, etc), and since it''s redundant, I''m closing it. Further discussion please in his first thread.

Share this post


Link to post
Share on other sites

This topic is 5652 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.

Guest
This topic is now closed to further replies.

  • Advertisement