Destructors
Go Up to Destructors Index
The destructor for a class is called to free members of an object before the object is itself destroyed. The destructor is a member function whose name is that of the class preceded by a tilde (~). A destructor cannot accept any parameters, nor will it have a return type or value declared.
#include <stdlib.h> class X { public: ~X(){}; // destructor for class X };
If a destructor is not explicitly defined for a class, the compiler generates one.