Timing of Constructor and Destructor Invocations

The term "constructor" implies that this member function constructs the object. The term "destructor" implies that this member function destroys the object. Do not fall into this trap. These terms describe the tasks performed by constructors and destructors incorrectly.

In the previous discussion, I was careful to point out that the constructor is called after the object is constructed, and the destructor is called before the object is destroyed. Often, C++ books do not pay attention to this difference and state that constructors and destructors are called when the objects are constructed and destroyed. This is unfortunate, because it makes programmers think that constructors construct objects ...

Get Core C++ A Software Engineering Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.