When class B is inherited from class A, what is the order in which the constructors of those classes are called

Options
- Class A first Class B next
- Class B first Class A next
- Class B's only as it is the child class
- Class A's only as it is the parent class


CORRECT ANSWER : Class A first Class B next

Discussion Board
C++ - Inheritance

When class B is inherited from class A, first class A's constructors are called and then class B's constructors are called. Because it indicates that class B is the base class and class A is a derived class.

Prajakta Pandit 01-25-2017 04:23 AM

Poor wording

You should rephrase this question. If "class B is inherited from class A", that tends to indicate that B is the base class. At best it's ambiguous.

Colin Rullkotter 12-31-2016 12:04 PM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement