Ну, нет широко известного, признанного способа сделать это.Если бы это было так, библиотеки GUI, использующие события и сигналы, вероятно, реализовали бы это.Однако есть и другие решения вашей проблемы.
Вы можете реализовать соединение сигнал-событие, используя boost.Signals, sigslot или что-то другое по вашему усмотрению.Как GTK + делает:
g_signal_connect(my_wdg, "expose-event", G_CALLBACK(my_func), NULL);
gboolean my_func(...)
{
// do stuff
return FALSE; /* this tells the event handler to also call the base class's slot */
}
Менее С-центрично, это может быть реализовано следующим образом:
/* In Granpa */
/* typedef a functor as 'DerivedEventHandler' or use a boost::function */
std::vector< DerivedEventHandler > handlers;
void connect(DerivedEventHandler event) { handlers.push_back(event); }
/* in loop */
while (! iter = handlers.end() ) /* call event */
/* In constructor of Father */
this->connect( this->OnLoad );
/* In constructor of Child */
this->connect( this->OnLoad );
/* and so on... in all derived classes */