Construction of objects

C++ allows you to define special methods to perform the initialization of the object. These are called constructors. In C++11, you will get three such functions generated for you by default, but you can provide your own versions if you wish. These three constructors, along with three other related functions, are as follows:

  • Default constructor: This is called to create an object with the default value.
  • Copy constructor: This is used to create a new object based on the value of an existing object.
  • Move constructor: This is used to create a new object using the data moved from an existing object.
  • Destructor: This is called to clean up the resources used by an object.
  • Copy assignment: This copies the data from one existing ...

Get Beginning C++ Programming 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.