Jump to content
  • Advertisement
Sign in to follow this  
Silex

STL vector

This topic is 4583 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, Quick C++ STL question: I'm using a vector container of a class I've written; since it uses dynamic memory, does the vector container need it to have a copy constructor and/or assignment operator for the erase method? I get around the problem for adding objects to it by having explicit load and unload functions that I call after using methods such as push_back, but I'm worried that internally the vector may be copying or assigning objects for erase. Can anyone clarify this? Cheers, Nick [edit] clarifications [Edited by - Silex on December 3, 2005 6:52:25 PM]

Share this post


Link to post
Share on other sites
Advertisement
Then try asking your question again. As far as I can tell you're only asking whether or not your class needs to have the copy constructor and assignment operator.

Share this post


Link to post
Share on other sites
erase() will call the assignment operator if you don't erase only elements at the end. If any elements are left between the erased elements and the end of the vector, they will have the assignment operator called.

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.

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

Sign me up!