The destructor is the counterpart of the constructor. It is a member function that is called automatically when a class object goes out of scope. Its purpose is to perform any cleanup work necessary before an object is destroyed. The destructor's name is the class name with a tilde (~) as a prefix.
The Date class doesn't really need a destructor. One is included in this example simply to show its format.
Destructors are required for more complicated classes, where they're used to release dynamically allocated memory. Chapter 5 describes such classes.
There is only one destructor for a class; you cannot overload it. A destructor takes no parameters and has no return value.