http://qs321.pair.com?node_id=103862


in reply to Tie & Destroy, OOP

The real problem here is that you're relying on a destructor to do real cleanup work. That's not a good idea because a.) destructors don't always get reliably called, b.) it's possible that you may end up referring to objects in your destructor that have already been destroyed (*ahem* :).

A destructor should be more of a "backup plan" that calls your "cleanup" routine a second time. That is, your "cleanup" rountine should be called at least once by you, and be written in such a way that it won't blow up if it gets called twice (because many times it will get called a second time by your "backup"..the destructor).