Constructor is a special member function its name is same as the class name.
- The constructor is invoked automatically whenever an object of its associated class is created.
- It is called constructor because it constructs the values of the data member of the class
types of constructor
there are different types of constructor available in c++.
- Default constructor
The constructor that accept no parameter is called default constructor.
2. parameterized constructor
The constructor that can take arguments are called parameterized constructor.
Characteristics of constructor
- They should be declared in the public section.
- They are invoked automatically when the objects are created.
- They do not have return (data type) type not even void and there for they cannot return any values.
- They can not be inherited, the a derived class can call the base class constructor.
- They make implicit calls to the operator new and delete when memory allocation is required.