adplus-dvertising
frame-decoration

Question

Which class destructor will be called first, when following code go out of scope?
class A{  };
class B{  };
class C: public B{  };
A a;
B b;
C c;

a.

~A()

b.

~B()

c.

~C()

d.

~B() and ~C()

Answer: (c).~C()

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which class destructor will be called first, when following code go out of scope?