codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <map> typedef int (*OutputEvent)(const char*, const char*, int); class A { private: int nextListenerId; std::map<int, OutputEvent> listenerMap; public: A(){ nextListenerId = 0;} ~A(){} inline int RegisterListener(OutputEvent callback) { nextListenerId++; listenerMap[nextListenerId] = callback; return nextListenerId; } }; class B { private: int listenerId; public: B(const A& a) { OutputEvent e = &B::CallMeBack; listenerId = a.RegisterListener(e); } ~B(){} int CallMeBack(const char* x, const char* y, int z) { return 0; } };
Private
[
?
]
Run code
Submit