6.1 Overall concepts

A destructor is the counterpart of a constructor. A destructor member function can specify exactly what needs to happen when an object is about to die. This may not sound useful for simple objects that do not point to other objects. However, once we start to have objects pointing to each other, destructors become extremely important.

The name of a destructor is the tilde symbol ~ followed by the class name.

Just as constructors must be public, destructors must be public, as well.



Copyright © 2006-09-26 by Tak Auyeung