Category: Proxy usage


Can I implement multiple callback interfaces in C++?


The answer is no. You can only implement one callback interface in C++ and there are some very good reasons for it. The callback mechanism relies on the fact that there is a Java type that implements the callback interface. This Java type has all the knowledge to delegate callback invocations to a C++ object that is maintained internally as a pointer.

If you implemented multiple callback interfaces in C++, you would be aggregating several Java implementations types in C++. Each type would only know how to handle its own callback methods, but not how to handle the callback methods of the other aggregated types.

If you wish to implement multiple callback interfaces, you have to have one Java interface which extends all the interfaces that you wish to use.

Copyright 2006-2011 by Codemesh, Inc., ALL RIGHTS RESERVED

frequently asked questions
home products support customers partners newsroom about us contact us