Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++vtable and vptr layoutSingle-choice MCQ

During construction of a base subobject in a class hierarchy, why can a virtual call dispatch to the base's implementation rather than the most-derived override?

struct B { B(){ f(); } virtual void f(){ std::puts("B"); } }; struct D : B { void f() override { std::puts("D"); } }; int main(){ D d; }