Jump to content
  • Advertisement
Sign in to follow this  

STL list problem [SOLVED]

This topic is 4139 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'm new to this list and template thing but I'm trying to add an element to a std::list but I'm having some problems... first I declare a list inside my class like so..
 std::list<CO_UI*> CO_UI_Elements; 

Then I have this function to add a new element to the front of the list...
CO_UI* CO_UI_Manager::AddUI_ElementToFront()
	CO_UI* NewUI_Element = new CO_UI;

        //Access violation get's spit out at this line.

	return CO_UI_Elements.front();

When I debug it points me to this line of the list code...
iterator begin()
		{	// return iterator for beginning of mutable sequence
		return (iterator(_Nextnode(_Myhead), this)); //Debug points here

I'm obviously doing something wrong but I don't know what. Anyone know? [Edited by - etsuja on May 23, 2007 4:46:38 PM]

Share this post

Link to post
Share on other sites
From experience such an error usually indicates that the CO_UI_Manager object you are calling the function AddUI_ElementToFront() on is not initialised, has been deleted or invalidated with some memory corruption (which we all pray is not the case).

Most likely it comes from calling the function on a bad pointer. Check higher in the call stack and find the code that is causing this, and the value of the pointer.

Debuggers often fill pointers with special values until you initialise them yourself. Look for this pointers with values that have a lot of repetition, such as 0xCDCDCDF8 (the last few bits are often different, usually generated by an offset into the object of the member being used ).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!