Observer pattern specialisation
问题 I'm trying to use the Observer pattern for some input stuff like so: class Observer { public: virtual void notify(Subject & o)=0; }; class Subject { public: virtual void register(Observer * o)=0; } I have two concrete Subjects (Mouse, Keyboard), with class specific functions that I want the concrete observer to call( getkeypress, getmousemotion etc). Is there any way to specialise the notify function in the concrete observer class without changing the interface, or downcasting the reference?