   attaching type to base class
  im trying to make a messagehandler systemthis is basicly how it looks nowive got a MessageClass{  virtual void onMsg() = 0;};WindowClass{  std::vector<MessageClass*> msgHandlers_;  void Attach(MessageClass* handler)  {msgHandlers.push_back(hanlder);  }  void WndProc()  {    BOOST_FOREACH(MessageClass* p, msgHandlers)    {  p->onMsg();    }  }};that was the base.. nowclass Application : MessageClass{  void CreateWindow()  {window = new Window;    window->Attach(this);  }  void onMsg();  Window* window;}this works fine.. when the WndProc in the window class is called the attached application class onMsg is called...but if i derive one more time...class Engine : Application{  void CreateWindow()  {    Application::CreateWindow();    window->Attach(this);  }  void onMsg();  Window* window;  }the problem now becomes that only the onMsg of "Engine" will be called... if ive understood correctly... what id like is that both of the onMsg are called.. first the Application onMsg then the Engine onMsg...on way i could solve this is with something like, attaching type to the base classtemplate <class T>void Attach(T* handler)and then somehow store the type and cast "handler" to that type when calling onMsg...suggestions?EDIT::and yes i know i could simple call Application::onMsg in the Engine class... but id like to avoid that if possible   
  Look into boost::function and boost::bind, then drop the virtual functions altogether, just bind the handler.Technically, you'd need to use boost::signal, but that one is known for atrocious performance.   ;  ok ive made a try.. it compiles however im getting an exception...#pragma onceclass Window : public drone::graphics::Window, boost::noncopyable{  typedef boost::function<void(    UINT uMsg, WPARAM wParam, LPARAM lParam, Window* pWindow)> MessageType;public:/****......*****/    template <class T>    void Attach(T* handler)    { msgHandle_ = boost::bind(&T::onMsg, handler, _1, _2, _3, _4);    }private:  MessageType msgHandle_;/****......*****/};typedef boost::shared_ptr<Window> WindowPtr;  } // namespace win32} // namespace droneLRESULT Window::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam){/****......*****/  msgHandle_(uMsg, wParam, lParam, this); return DefWindowProc(hWnd_,uMsg,wParam,lParam);}EDIT::boost::bad_function_call at memory location 0x0012eb24..   ;  Much simpler way would be to call your base class implementation.// engine implementationvoid onMsg(){  Application::onMsg();};  sure it would be simpler... but it would be harder for other people to use the class... how would they know that you have to include that if they derive from Engine?   ;  If someone is going to derive from your Engine class, they're gonna know that Engine::onMsg() needs to be called if they override it.  If they don't override it, the Engine::onMsg method will be called anyway since that is what deriving a class is for, inheriting functionality.Really, an 'engine' shouldn't be deriving from the 'application' class anyway.  You're tight-coupling it to a particular windowing system.  I would instead make a 'game' class that you instance and bind a call to it's update through some sort of timer message.  But that's just me.And, by looking at some of your previous posts, you're pretty new to window's programming so worrying about how someone else is going to derive from your classes is not worth your time.  Write code then write some more code.  It's the best way to learn.  Don't get bogged down in semantics.Happy coding.   ;  I'm not exactly sure given the lack of code, but doesn't message callback procedure need to be a static function?Usually, you'd bind the some parameter to your instance of class, so that the actual callback knows who to notify.This might help.   