0
Constructor base and derived classes.
When object of derived class is created, then which one is true: 1. Constructor of base class is invokes first. 2. Constructor of base class is invoked first then followed by invocation of derived class' constructor. 3. Constructor of base class is executed first then followed by excution of derived class' constructor. 4. Constructor of derived class' is invoked first then followed by invocation of base class' constructor. Thank you for your help.
1 Answer
+ 3
Option 2.
Reason:
A derived class inherits all the members of the base class, and the constructor of the derived class needs to ensure that the base class members are properly initialized before initializing any members specific to the derived class.