What are the Constructors?

Constructors are the member functions of class which have the same name as that of class name and are used to initialize data of class which is also known as member data.
Constructors are basically used to assign values to the variables of class as we cannot assign values to them at the time of their declaration. We do not have to call them as they are called automatically when we create an object of class.

Features of Constructors:
1. Constructors have same name as that of class name.
2. They are basically used to give initial values to the data of class.
3. They are automatically called by the compiler when object of the class is created.
4. We can overload the constructors. Defining multiple constructors in a class is known as Constructor overloading.

Types of Constructors:
1. Default Constructor
2. Parameterized Constructor
3. Copy Constructor

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.