August 2012
Intermediate to advanced
976 pages
30h 17m
English
The destructor operates inversely to the constructors: Constructors initialize the nonstatic data members of an object and may do other work; destructors do whatever work is needed to free the resources used by an object and destroy the nonstatic data members of the object.
The destructor is a member function with the name of the class prefixed by a tilde (~). It has no return value and takes no parameters:
class Foo {public: ~Foo(); // destructor // ...};
Because it takes no parameters, it cannot be overloaded. There is always only one destructor for a given class.
Just as a constructor has ...
Read now
Unlock full access