Which of the following is true about constructors in C++ ?

2025

Which of the following is true about constructors in C++ ?

  1. A.

    Constructors must return a value

  2. B.

    Constructors are called automatically when an object is created

  3. C.

    A constructor must take parameters

  4. D.

    Constructors can have any name

Attempted by 51 students.

Show answer & explanation

Correct answer: B

In C++, constructors are special member functions that initialize objects of a class. They have the same name as the class and do not return any value, not even void.

Explore the full course: Tpsc Assistant Technical Officer