Constructor is just like a method that is used to initialize the state of an object. It is invoked at the time of object creation.
• A constructor is a special method whose task is to initialize the object of its class.
• It is special because its name is the same as the class name.
• They do not have return types, not even void and therefore they cannot return values.
• They cannot be inherited, though a derived class can call the base class constructor.
• Constructor is invoked whenever an object of its associated class is created.
Constructor is a special member function of a class, which is invoked automatically whenever an
instance of the class is created. It has the same name as its class.