Jump to content
  • Advertisement

Archived

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

vectors, how to remove parts of the array?

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

say ive got:
vector <int> number;
number.push_back(0);
number.push_back(1);
number.push_back(2);
number.push_back(3);
number.push_back(4);
how would i remove number 2? that is number[2] Thanks,

Share this post


Link to post
Share on other sites
Advertisement
If you routinely remove elements from the front, and don''t need contiguous storage, use a deque instead of a vector, and call pop_front().

Share this post


Link to post
Share on other sites
quote:
Original post by Nervo
when you erase the element do cout << number.size();

and see what it tells you.
Learn to use your debugger instead of littering your code with cout statements. (Yes, you can''t display the contents of Standard Library containers in the debugger in VC6 - natively; expand them and look at their internal data structures.)

Share this post


Link to post
Share on other sites
quote:
Original post by SiCrane
"Doesn''t seem to work" is rather vague.


You should be used to that answer by now.

Share this post


Link to post
Share on other sites

  • 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!