Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 9. C++ Class as a Unit of Modula... > Timing of Constructor and Destructor...

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 and destructors destroy objects.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial