View Single Post
  #5  
Old August 17th, 2006, 05:49 PM
PvK's Avatar

PvK PvK is offline
National Security Advisor
 
Join Date: Dec 1999
Posts: 8,806
Thanks: 54
Thanked 33 Times in 31 Posts
PvK is on a distinguished road
Default Re: OT: Stupid c++

Classes should define a destructor if something needs to happen every time one gets destroyed (either by delete or by a non-static member going out of scope). It is important to prevent memory leaks if the class has any heap-allocated memory that it maintains the only pointer to and should remove when it dies.

If an object has no heap-allocated memory (i.e. it doesn't create anything with "new" or "malloc"), and if nothing needs to happen when it gets deleted, then it doesn't need a destructor.

However, I really doubt any worthwhile C++ compiler is going to have a fundamental problem with destructors or with delete. If it did, it would be seriously crippled. I expect probably you are seeing some other bug.

What are you deleting when you see problems? Objects with destructors that do things like use objects that are already destroyed?
Reply With Quote