TITLE: Callbacks and multiple inheritance, part IV This example is based upon "Subobject Members", Stephen Dewhurst, C++ Report, V5 N3. This is part 4 of a multipart example. The final part of this example is shown below: ................................................................. class Engine { // ... public: void start (); void stop (); private: class StartButton : public Button { void press (); } start_b; friend StartButton; class StopButton : public Button { void press (); } stop_b; friend StopButton; }; void Engine :: StartButton :: press () { C_addr (Engine, start_b)->start (); } void Engine :: StopButton :: press () { C_addr (Engine, stop_b)->stop (); } ................................................................. This solution relies on the "offsetof" facility defined in stddef.h. An appropriate define would be: #define C_addr(C, M) ((C*)(((char*)this)-offsetof(C, M))) "An important feature of this solution is that, unlike the previous solution, the [...] members do not require explicit initialization from the containing object".