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

During the constructor of a base class B (while a derived D object is being built), a virtual call to an overridden method resolves to B's version, not D's. Mechanically, why?

struct B { B(){ f(); } virtual void f(){ /* B::f */ } }; struct D : B { void f() override { /* D::f */ } }; D d; // B's constructor calls B::f, not D::f