View Single Post
  #2 (permalink)  
Old 10-07-2007, 06:31 AM
Bench Bench is offline
Full Programmer
Join Date: Jul 2007
Location: UK
Posts: 116
iTrader: (0)
Bench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished road
No, the lack of a destructor doesn't cause memory leaks. Forgetting to delete memory causes memory leaks. A destructor is sometimes useful if you have new'ed memory somewhere and you wish for your class to clean up after itself. In this case, writing a destructor can help, in most cases, you'll not need to write one.


The syntax is similar to a constructor (Except that it must take 0 arguments and cannot be overloaded), but with the bit complement operator in front
Code:
class myclass
{
    ~myclass()
    {
        //delete etc.
    }
};

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to Bench For This Useful Post:
HelloWorld (10-07-2007)