Which among the following best describes the constructors?

Which among the following best describes the constructors?
A. A function which is called whenever an object is referenced
B. A function which is called whenever an object is created to initialize the members
C. A function which is called whenever an object is assigned to copy the values
D. A function which is called whenever an object is to be given values for members
 
Answer: b
Explanation: The constructors are special type of functions which are called whenever an object is created. This is to initialize the data members of the class. The constructor allocates memory space for all the data members.
 

Tìm kiếm

Back
Top