为什么不在C#和java中进行多重继承 [英] Why not multiple inheritance in C# and java

查看:60
本文介绍了为什么不在C#和java中进行多重继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以解释为什么在java和c中没有使用多重继承的原因#c /

谢谢,

Mahesh

-

祝你有个美好的一天,

Mahesh,
Ma ************ @ yahoo.co.in

推荐答案

MAHESH MANDHARE< ma *************** @ yahoo.co.in>写道:
MAHESH MANDHARE <ma***************@yahoo.co.in> wrote:
任何人都可以解释我为什么在java和c#
Can Anyone explain me exactly why multiple inheritance not used in java and c#

中没有使用多重继承

基本上是因为它们会在
语言,这可能意味着代码中的额外复杂性(无论是否b / b,这意味着代码更加复杂,或者只是更难以理解)一瞥)。


还认为实现的多重继承很少非常有益。请注意,.NET和Java中仍然存在多个继承

的接口。


我自己从未使用过多次继承实现,我

不能评论它有多少损失,但我不能说我经常会想到b $ b想到哦,我希望我能从两者中得到这些类中的在我的

代码中。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复该组,请不要给我发邮件



Basically because they introduce additional complexity into the
language which can then mean additional complexity in the code (whether
it means the code being more obviously complicated, or just harder to
understand at a glance).

It was also considered that multiple inheritance of implementation is
rarely very beneficial. Note that there is still multiple inheritance
of interface in both .NET and Java.

Never having used multiple inheritance of implementation myself, I
can''t comment on how much of a loss it is, but I can''t say I''ve often
thought "ooh, I wish I could derive from both of these classes" in my
code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


http://blogs.msdn.com/csharpfaq/arch.../07/85562.aspx


我的个人观点(值得一提的是!)真的很遗憾不包括这个(不管所有潜在的陷阱)。几年前听完Anders的演讲后,我得到的印象是他真的不喜欢b $ b。但我想只有少数情况我认为我真的希望能够做到这一点...但也许我的方法

是不同的因为我知道我不能。


Br,


马克。


" MAHESH MANDHARE <毫安*************** @ yahoo.co.in>在消息中写道

新闻:3B ********************************** @ microsof t.com ...
http://blogs.msdn.com/csharpfaq/arch.../07/85562.aspx

My personal opinion (for what it is worth!) is that it is a real shame not
to include this (regardless of all the potential pitfalls). Having heard a
speech by Anders a couple of years back, I got the impression that he really
didn''t like it. But I guess that there has been only a few occasions that I
thought that I really wanted to be able to do this ...but maybe my approach
is different because I know I can''t.

Br,

Mark.

"MAHESH MANDHARE" <ma***************@yahoo.co.in> wrote in message
news:3B**********************************@microsof t.com...

任何人都可以解释为什么在java中没有使用多重继承
和c#
谢谢,
Mahesh <有一个美好的一天,
Mahesh,
Ma ************ @ yahoo.co.in



来自Anders的提案Hejlsberg为C#接口增加了对默认

实现的支持,这就像MI的有限支持

但听起来很有用。

Jon Skeet [C#MVP]" < SK *** @ pobox.com> schrieb im Newsbeitrag

新闻:MP ************************ @ msnews.microsoft.c om ...
There is a proposal from Anders Hejlsberg to add support for a default
implementation to interfaces to C#, this is something like a limited support
for MI but sounds useful.
"Jon Skeet [C# MVP]" <sk***@pobox.com> schrieb im Newsbeitrag
news:MP************************@msnews.microsoft.c om...
MAHESH MANDHARE< ma *************** @ yahoo.co.in>写道:
MAHESH MANDHARE <ma***************@yahoo.co.in> wrote:
任何人都可以解释我为什么在java中没有使用多重继承
Can Anyone explain me exactly why multiple inheritance not used in java


和c#
基本上是因为它们在
语言中引入了额外的复杂性然后可能意味着代码中的额外复杂性(无论是否意味着代码更复杂,或者更难以一目了然地理解)。

它也被认为是实现的多重继承很少非常有益。请注意,.NET和Java中仍然存在多个接口继承。

我自己从未使用过多次继承,我不能评论多少它是一种损失,但我不能说我经常想到哦,我希望我可以从这两个类中得出在我的
代码中。

-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复小组,请不要给我发邮件

and c#
Basically because they introduce additional complexity into the
language which can then mean additional complexity in the code (whether
it means the code being more obviously complicated, or just harder to
understand at a glance).

It was also considered that multiple inheritance of implementation is
rarely very beneficial. Note that there is still multiple inheritance
of interface in both .NET and Java.

Never having used multiple inheritance of implementation myself, I
can''t comment on how much of a loss it is, but I can''t say I''ve often
thought "ooh, I wish I could derive from both of these classes" in my
code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too



这篇关于为什么不在C#和java中进行多重继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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