1.

What is constructor?

Answer»

The definition of a class only creates a new user defined data type. The instances of the class type should be instantiated (created and initialized). Instantiating object is done using constructor. An array or a structure in C++ can be initialized during the time of their declaration.

The initialization of class type object at the time of declaration similar to a structure or an array is not possible because the class members have their associated access specifiers (private or protected or public). Therefore Classes include special member functions called as constructors.

The constructor function initializes the class object.



Discussion

No Comment Found