You shouldn't delete &itr. First of all, you're deleting a pointer to the iterator, and you never allocated that yourself.
Secondly, if you want to delete your old object, you probably don't need to. If it's not a pointer, erase will do everything for you. Unless you have a specific function that does cleaning up, you can call that now.
If you never allocated your Object_Alien, you don't need to delete it.
I presume you initialize your Object_Aliens by doing something like:
1 2 3
|
Object_Alien ob;
_objects.push_back(ob);
| |
In that case, just calling
_objects.erase(itr);
is fine!
edit: I overlooked you saying that they are allocated with the new statement. When you place such objects in a vector, a copy is made. So your original allocated data is now lost and you can't delete that anymore. You need to store the pointers in an array, and delete those:
std::vector<Object_Alien*> _objects;