Which of the following statements about a C++ constructor is correct?

Options

  • A. A constructor can be virtual
  • B. A constructor cannot be virtual
  • C. A constructor must always be static
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. A constructor cannot be virtual

Detailed Explanation

Answer: (B) A constructor cannot be virtual

A C++ constructor cannot be declared virtual.

Virtual functions require an already existing object so that runtime dispatch can determine which overridden function should execute. A constructor, however, is responsible for creating and initializing the object itself.

Therefore, declaring a constructor as virtual is not allowed in C++.