Sign in to follow this  

STL list problem [SOLVED]

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this