30 lines · cpp
1static int g_next_value = 12345;2 3struct VBase {4 VBase() : m_value(g_next_value++) {}5 virtual ~VBase() {}6 int m_value;7};8 9struct Derived1 : public virtual VBase {10};11 12struct Derived2 : public virtual VBase {13};14 15struct Joiner1 : public Derived1, public Derived2 {16 long x = 1;17};18 19struct Joiner2 : public Derived2 {20 long y = 2;21};22 23int main(int argc, const char *argv[]) {24 Joiner1 j1;25 Joiner2 j2;26 Derived2 *d = &j1;27 d = &j2; // breakpoint 128 return 0; // breakpoint 229}30