DDDerived class dtor, which should not explicitly invoke C or B.
CCComponent (ie field) dtor
CCComponent of BBBase class
Compiler arranges these steps to execute in a single thread. See P277 ARM
A1: same DCBC according to EffC++. I probably tested it.
A3: See P60 [[safe c++]]. The exception triggers stack unwinding — C B C. Exact same sequence except the very first step i.e. the D is skipped. Derived dtor is skipped because Derived ctor didn’t complete.
The simple rule in this “exceptional” scenario is “
whenever a ctor completes without throwing, its dtor would be executed.”
A2: constructed First, so destructed Last. Remember dtor^ctor is ALWAYS reverse order
Q1: but what if i invoke Derived virtual dtor through “delete”?
Q2: Virtual base?
Q3: what if the derived ctor throws exception after B and C completed? Which dtors will/won’t run and in what order?
(To aid blog search, D-C-B-C)