Multiple choice

Consider the following C++ code and select its output from the given options:

class A{ int a; public: A(int x) {cout<< Base Constructor:<

  1. Derived constructor:Base constructor:

  2. Base constructor:Derived constructor:

  3. Default constructor:Base constructor:

  4. Derived constructor:Default constructor:

  5. Base constructor:Base constructor:

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is the correct output of the above C++ code. If the constructor function is used in both base and derived classes, then always the base constructor function would be executed first and then derived constructor.