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

2025

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

  1. A.

    Constructors can return values

  2. B.

    A constructor has the same name as the class

  3. C.

    Constructors must have parameters

  4. D.

    Constructors can be invoked explicitly

Attempted by 44 students.

Show answer & explanation

Correct answer: B

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

Explore the full course: Tpsc Assistant Technical Officer