What is constructor overloading in C++?

Options

  • A. Defining multiple constructors with different parameter lists
  • B. Defining multiple destructors in a class
  • C. Using a constructor outside the class only
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. Defining multiple constructors with different parameter lists

Detailed Explanation

Answer: (A) Defining multiple constructors with different parameter lists

Constructor overloading means defining more than one constructor in the same class with different parameter lists.

For example, a class can have one constructor with no parameters, another with one parameter, and another with two parameters.

The compiler determines which constructor to call based on the arguments supplied while creating the object.

This is an example of compile-time polymorphism.