Background — How important are these scenarios? First off, tech quizzes are extremely important since you are judged just over a few questions. Second, these scenarios pop up by accidents, rather than be design, all the time in real projects. You better learn to deal with a drunken driver while on the road.
Q: what if Base and Derived dtor both non-virtual and an autoVar is destroyed?
%%A: see post on DCBC.
Q: What if Base dtor is not virtual but Derived is virtual, and a Derived auto variable is destroyed on the stack?
%%A: For an autoVariable that’s not deleted via a ptr, Derived ctor (virtual or not) runs, followed by Base dtor. Same DCBC
Note the well-known __undefinedBehavior__ affects delete only, not stack variables or static variables.
Note virtual keyword affects pointer variable. Non-ref variables aren’t affected.