Classes: A Deeper Look,: C++ How To Program, 7/e
Classes: A Deeper Look,: C++ How To Program, 7/e
2/3/11
2/3/11
2/3/11
2/3/11
2/3/11
Demo
ObjectSize.cpp
2/3/11
9.7 Destructors
The name of the destructor for a class is the tilde character (~) followed by the class name. Often referred to with the abbreviation dtor in the literature. Called implicitly when an object is destroyed. The destructor itself does not actually release the objects memoryit performs termination housekeeping before the objects memory is reclaimed, so the memory may be reused to hold new objects. Receives no parameters and returns no value. May not specify a return typenot even void. A class may have only one destructor. A destructor must be public. If you do not explicitly provide a destructor, the compiler creates an empty destructor.
1992-2010 by Pearson Education, Inc. All Rights Reserved.
Constructors are called for objects defined in global scope before any other function (including main) in that file begins execution (although the order of execution of global object constructors between files is not guaranteed).
The corresponding destructors are called when main terminates.
1992-2010 by Pearson Education, Inc. All Rights Reserved.
2/3/11
Demo
CtorDtor.cpp