In Book The next line after the constructor the destructor. This has the same name as the constructor but with a ~ (tilde) in front of it. During the destruction of an object, the destructor is called to tidy up the object, and ensure that resources such as memory and file handles used by the object are released.
Remember : A class xyz has a constructor function xyz() and destructor function ~xyz(). Even if you don't declare then the compiler will silently add them.
The destructor is always called when the object is terminated. In this example the object is implicitly destroyed when it goes out of scope. To see this, modify the destructor declaration to this.
~Book(){ std::cout << "Destructor called\n";} ; // DestructorThis is an inline function with code in the declaration. Another way to inline is adding the word inline.
inline ~Book() ; // Destructorand add the destructor as a function like this.
inline Book::~Book ( void ) {Inline functions are hints to the compiler to generate more efficient code. They should only be used for small functions, but if used in appropriate places such as inside loops can make a considerable difference in performance.
std::cout << "Destructor called\n";
}
On the next page : Learn more about class methods

