Constructor in c++:
Constructor is a member function i.e. invoked ( to call) automatically when an object is declared. The constructor function must have the same name as the class itself and it is declared without return type or A constructor is a special member function whose task is to initialize the class. It is special because its name is same as the class name.
• A constructor having the same name as that of the class name to which it belongs.
• Constructor is declared in the public section of a class
• A constructor is executed automatically whenever the objects of a class are created.
• Constructor does not return type, not even void can be specified for a constructor.
• A constructor can be called in the way a normal function is called
• Constructors are also use to allocate memory at run time usually the new operator.
Types of contructors:
1. Default Constructor
2. Parametrized Constructor
3. Copy Constuctor