C++ provides mechanisms for ensuring that your objects are initialized properly before they are used. As your objects go in and out of scope, memory is first allotted to them and then initialized. C++ provides a special member function called the constructor for the initialization of an object.
A constructor function is called whenever an object is created. An object can be created as a global variable, as a local variable, through the explicit use of the new operator, though an explicit call of a constructor or as a temporary object. Constructors are called when an object is created as part of another object. LEARN MORE>>