Which of the following statement is correct about constructors in C++?

185. Which of the following statement is correct about constructors in C++?

  1. A constructor is used to destroy an object.
  2. Constructor is used to initializing data members when an object gets created.
  3. Constructor is used to call the private function from outside the class.
  4. None of the above

Answer: B) Constructor is used to initializing data members when an object gets created.

Explanation:

Constructor is a special type of member function that automatically calls when an object gets created. It is used to initialize the data members of the class.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.