ProgrammingEasyAccenture · Cognizant pattern

What is the return type of a C++ constructor?

  1. A. int
  2. B. The class type
  3. C. It has no return type, not even void
  4. D. void

Correct answer: C. It has no return type, not even void

A constructor is declared with the class name and no return type at all; writing void before it makes it an ordinary (badly named) function instead.

More OOP with C++ and Java questions

Exams that ask this topic