If there are 3 classes. Class C is derived from class B and B is derived from A, Which class destructor will be called at last if object

If there are 3 classes. Class C is derived from class B and B is derived from A, Which class destructor will be called at last if object of C is destroyed.
A. A
B. B
C. C
D. All together
 
Answer: a
Explanation: The destructors are called in the reverse order of the constructors being called. Hence in multilevel inheritance, the constructors are created from parent to child, which leads to destruction from child to parent. Hence class A destructor will be called at last.
 

Tìm kiếm

Back
Top