tags:

views:

76

answers:

1

Can I implement multiple callback interfaces in C++ for Java?

+2  A: 

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.

carlfilips