Is it possible to implement multiple callback interfaces in C ++?

Is it possible to implement multiple callback interfaces in C ++ for Java?

+4
source share
1 answer

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

If you implemented several callback interfaces in C ++, you would combine several types of Java implementations in C ++. Each type would only know how to process its own callback methods, but not how to handle callback methods of other aggregate types.

+1
source

All Articles