Created
November 29, 2012 06:56
-
-
Save leifbladt/4167269 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Broker { | |
public: | |
void subscribe(void (*f)()) { | |
_f = f; | |
} | |
void notify() { | |
(_f)(); | |
} | |
private: | |
void (*_f)(); | |
}; | |
class B { | |
public: | |
B(Broker* b) { | |
_b = b; | |
// error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function. Say '&B::c' | |
// error: no matching function for call to 'Broker::subscribe(void (B::*)())' | |
// note: candidates are: void Broker::subscribe(void (*)()) | |
_b->subscribe(&c); | |
} | |
void c() {} | |
private: | |
Broker* _b; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment