Possible Duplicate:
Should objects delete themselves in C++?
In my application, I'm creating many objects that "own themselves" - in the sense that after they are created and told to "go," only the object itself can determine when it should be deleted.
For example, if I was writing a game, I might have multiple Enemy
objects. Only the Enemy
object knows when it should die.
As a result, I end up using delete this
inside some of the member functions inside the Enemy
object. Is this bad form? Is this something I should avoid, and if so, what is the correct way to handle this type of situation?