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:
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.
|
 |
|
 |