Archived

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

Debug Assertion Failed std::vector push_back

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

Hi all, I''m having a problem attempting to push an instance of one of my classes onto the end of a vector. The following is the code that causes the problem:
//theTextPanels is declared like: vector <TBTextPanel> theTextPanels;

TBTextPanel textControl;
theTextPanels.push_back(textControl);
When the push_back is called the following error is shown: Debug Assertion Failed File: dbgheap.c Line: 1044 Expression: crtIsValidHeapPointer(pUserData) I''ve stripped the TBTextPanel class down so all it contains is its constructor and destructor. The strange thing is that I have another class that I have done the same to but when using push_back on that it works fine. Also if I make the TBTextPanel inherit from TBControl and then add it to a vector of TBControls it doesn''t throw up an error. But still does if I add it to a vector of TBTextPanels. All references to this error I have seen while searching seem to relate to deleting pointers etc. If anyone could help I would be grateful. Thanks.

Share this post


Link to post
Share on other sites
I''m using the default copy constructor/destructor i.e. I haven''t defined one.

It seems strange that I would need to since I don''t have member variables in the TBTextPanel class. Also the program dies before the textControl instance of TBTextPanel is destroyed.



Share this post


Link to post
Share on other sites
If you''re using visual studio, you might try a "rebuild all" just in case. Occasionally it has trouble compiling when only parts of your code need recompiling.


"Unfortunatly, when I sent the email, instead of writing "Best Regards" I ended up writing "Best Retards." - boolean

Share this post


Link to post
Share on other sites