18 lines · c
1#ifndef B_H2#define B_H3 4#include "a.h"5 6class B : virtual public A {7 virtual void x() {}8};9 10void b(A* p) {11 p->x();12 // Instantiating a class that virtually inherits 'A'13 // triggers calculation of the vtable offsets in 'A'.14 B b;15}16 17#endif18