I don't think you follow what I meant: When destroying something WITHIN a vector, it doesn't mean that the vector element itself is removed - just that the object the vector held in itself is destroyed. Which, as CornedBee is saying, is undefined behaviour [and it will most often actually work fine for small test-cases, but crash badly when in a more complex setup].

To remove something from within a vector, you need to use a function like vector::erase().

--
Mats

Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.

Okay, but I think you also misunderstand the purpose of my post. It wasn't to create my own erase function to use on std::vector, but instead an erase function for my own class that is supposed to mimic a vector (it was a chapter exercise). Sorry if I wasn't being clear about that in the beginning...