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

During construction of a polymorphic object with a base class, why does calling a virtual function from inside the *base* class constructor dispatch to the base's version, not the derived override, at the machine level?

struct B { B(){ init(); } virtual void init(); }; struct D : B { void init() override; }; // D d; -> which init() runs from B::B()?