开发者

Have a way to simulate diamond problem with Java [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

Have a way to simulate the diamond problem with Java ? With interfaces ?

Thanks, Cel开发者_Go百科so


In Java you can never have a diamond problem. It's designed not to have multiple inheritance.

Diamond problem comes when you have multiple data members and function member with solid definition in the super base class. However, in Java you can only have interface getting implemented; which never can contain anything other than pure virtual methods and static const members (in C++ context).


Java avoids the diamond problem by enforcing single-inheritance for classes and allowing multiple inheritance for interfaces.

It's not really a problem when interfaces form a diamond.

You can get a Javadoc diamond problem, but I guess that's not what you're looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜