Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++multiple and virtual inheritance layoutSingle-choice MCQ

For the multiple-inheritance layout below, what is the runtime mechanism that makes a virtual call to f() correct when invoked through a B* that points into a D object?

struct A { virtual void g(); int a; }; struct B { virtual void f(); int b; }; struct D : A, B { void f() override; int d; }; B* p = new D; p->f(); // dispatches to D::f