Listener-style Interface in C++

Oct 26, 2010 1 Replies

A common use for anonymous inner classes in Java is listeners. There is an article about how to write event listener in Java with event adapters

formatting link
In java98 I think it is called Listener Paradigm.



There must be some equivalent listener-style interfaces to be seen in C



++, however, I am not aware of any at this moment. Could anybody please share some

knowledge with me about listener-style interfaces in C++? Can I implement an equivalent Listener Paradigm in C++ with event adapters? IS there any sample



around by customerizing the OBSERVER pattern?



Thanks!


You should google for "Observer Pattern".

C++0x supports lambdas, which is one better than inner classes. You don't need them though, you can just use interfaces (multiply inheritable classes with no variables and no private methods).

Now go and do your own homework ;-)

Clifford Heath.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required