Google News
logo
CPP - Quiz(MCQ)
What is the role of a constructor in classes?
A)
To destroy an object
B)
To modify the data whenever required
C)
To initialize the data members of an object when it is created
D)
To call private functions from the outer world

Correct Answer :   To initialize the data members of an object when it is created


Explanation : A constructor is used in classes to initialize data members of class in order to avoid errors/segmentation faults.

Advertisement