Erasing element from Vector
问题 In C++, how can I delete an element from a vector? Delete it right from where it is, i.e. let the vector resize Swap the element to be deleted with the last element s.t. pop_back() can be used (which I hope doesn't involve copying everything around...) For (1), I've tried the following, but I'm not quite sure if it does what it is supposed to do (remove the item passed to removeItem() ), and it doesn't seem very elegant: vector<Item*> items; // fill vector with lots of pointers to item