If in multiple inheritance, class C inherits class B, and Class B inherits class

If in multiple inheritance, class C inherits class B, and Class B inherits class A. In which sequence are their destructors called if an object of class C was declared?
A. ~C() then ~B() then ~A()
B. ~B() then ~C() then ~A()
C. ~A() then ~B() then ~C()
D. ~C() then ~A() then ~B()
 
Answer: a
Explanation: The destructors are always called in the reverse order of how the constructors were called. Here class A constructor would have been created first if Class C object is declared. Hence class A destructor is called at last.
 

Tìm kiếm

Back
Top