Code About Us Tutorial


  Basic Classes
    What is a Class?
    Class Functions
    Creating Class Objects
    Constructors
    Destructors


   
 

Home > Basic Classes > Destructors

November 27, 2009 1:12 am

   

Destructors

Now that we understand constructors we can move onto destructors.

A Class destructor is just the opposite of a constructor, the destructor “destroys” the object and releases all memory allocated for the object. Like the constructor, the default destructor is always called and contains no parameters. The syntax of a destructor is:

 

 
~ClassName();

The following would be an example of the default Employee destructor:

 

 
~Employee();   			//destructor

The destructor can not take any parameters nor can it return a value. It is always a good idea to write the default constructor if you defined your own constructor to make the code cleaner. Please Rate this Code:


    Comments for: Destructors
  There are NO user contributed comments for Destructors.



Add Comment:
Name:
Email:


 «2» THINKQUEST TEAM C0111571 © 2001. All Rights Reserved.