开发者

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

开发者 https://www.devze.com 2023-03-22 10:38 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
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

精彩评论

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

关注公众号