为什么C#net不支持Mul.inheritance? [英] WHy C#net doesnot support Mul.inheritance?

查看:86
本文介绍了为什么C#net不支持Mul.inheritance?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么C#.net不支持多重继承?为什么它可以按接口支持?为什么不按类?

Why C#.net does not support multiple inheritance?why it can support by interface?why not by class?

推荐答案

因为设计者决定为了使它更安全",削弱了该语言. X |

接口的实现与继承无关.
Because the designers decided they''d cripple the language in the interests of making it "safer". X|

Implementing an interface is unrelated to inheritence.


由于 ^ ].

这是简短的摘要:
C# and Java languages don''t support multiple inheritance because of the diamond problem[^].

Here is the short summary:
当两个B类和C类从A继承而D类从两个B继承时,钻石问题就产生了歧义.如果D中的方法调用了A中定义的方法(并且不覆盖该方法),并且B和C以不同的方式覆盖了该方法,则它从哪个类继承:B或C?






这篇关于为什么C#net不支持Mul.inheritance?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆