2

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

1
  • I don't understand the question. Any Java class can implement multiple interfaces, and any C++ class can extend multiple classes. How you hook them together is up to you. Commented Aug 4, 2010 at 4:15

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.