#include using namespace std; struct A { virtual void invoke() { std::cout << "Goodbye from A" << endl;} }; struct Invoker { Invoker (A *a) { a->invoke();}; }; class B: A, Invoker { public: B() : A(), Invoker(this) {} void invoke() { cout << "Hello World from B" << endl;} }; class C: A, Invoker { public: C() : Invoker(this), A() {} void invoke() { cout << "Hello World from C" << endl;} }; // this undefined becuase A::invoke is called, before A is built class D: Invoker, A { public: D() : Invoker(this), A() {} void invoke() { cout << "Hello World from D" << endl;} }; int main() { B b; C c; b.invoke(); c.invoke(); cout << "creating D is undefined becuase A::invoke is called, before A is built" << endl; cout << "BOMBS AWAY!!!" << endl; D d; d.invoke(); return 0; }