奇怪,但C#确实允许多重继承,只要它是串行的 [英] Strange, but C# does allow multiple inheritance, so long as it's serial

查看:160
本文介绍了奇怪,但C#确实允许多重继承,只要它是串行的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯,与我2000年关于C#的教科书(公共版本的b $ b测试版)的含义相反,C#确实允许多重继承,只要它是

串行链接如下:


class derived02:derived01

{


}

class derived01:baseclass01

{

}


class baseclass01

{

}





你不能从多个基类继承(你必须使用)一个

接口,只需复制所有基类,比如虚拟基础
$ c $ b C ++课程)


RL

Well, contrary to the implication in my 2000 textbook on C# (public
beta version), C# does allow multiple inheritance, so long as it''s
serially chained as follows:

class derived02 : derived01
{

}

class derived01 : baseclass01
{
}

class baseclass01
{
}

etc

You just can''t inherit from multiple base classes (you have to use an
Interface and simply replicate all base classes, like a virtual base
class in C++)

RL

推荐答案

我不确定这是回复上一篇文章,还是什么,但是什么

你所描述的并不是真正的多重继承,因为它通常被理解为
。抱歉。


Marc

I''m not sure if this was a reply to a previous post, or what, but what
you have described is not really multiple inheritance as it is
normally understood. Sorry.

Marc


raylopez99< ra ******** @ yahoo.comwrote :
raylopez99 <ra********@yahoo.comwrote:

嗯,与我2000年关于C#的教科书(公共



class derived02:derived01

{


}


class derived01:baseclass01

{

}


class baseclass01

{

}





你刚才不能从多个基类继承(你必须使用一个

接口,只需复制所有基类,比如C ++中的虚拟基础

类)
Well, contrary to the implication in my 2000 textbook on C# (public
beta version), C# does allow multiple inheritance, so long as it''s
serially chained as follows:

class derived02 : derived01
{

}

class derived01 : baseclass01
{
}

class baseclass01
{
}

etc

You just can''t inherit from multiple base classes (you have to use an
Interface and simply replicate all base classes, like a virtual base
class in C++)



我还没有看到任何多重继承的定义。

包括那个。 derived02继承自derived01,而依次是

继承自derived01。


-

Jon Skeet - < sk * **@pobox.com>
http://www.pobox.com/ ~Sibet 博客: http://www.msmvps.com/jon。双向飞碟

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

I haven''t seen any definition of "multiple inheritance" which would
include that. derived02 is inheriting from derived01, which in turn
inherits from derived01.

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


Ray,

真正的多重继承看起来像这样:


class derived01:base01,base02

{

//其中base01和base02是你想要的两个类派生的元素来源于,而不是用C#来完成的。抱歉。

}

-

递归:见递归

网站: http://www.eggheadcafe.com

unBlog: http://petesbloggerama.blogspot.com

BlogMetaFinder: http://www.blogmetafinder.com


" raylopez99"写道:
Ray,
true multiple inheritance would look like this:

class derived01 : base01, base02
{
// where base01 and base02 are both classes that you want derived01 to
derive from, which cannot be done in C#. Sorry.
}
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"raylopez99" wrote:

嗯,与我2000年关于C#的教科书(公共

beta版)的含义相反,C#确实允许多重继承,只要按照以下顺序链接



class derived02:derived01

{
< br $>
}


class derived01:baseclass01

{

}


class baseclass01

{

}





你只是不能从多个基类继承(你必须使用一个

接口,只需复制所有基类,比如C ++中的虚拟基础

类) />

RL

Well, contrary to the implication in my 2000 textbook on C# (public
beta version), C# does allow multiple inheritance, so long as it''s
serially chained as follows:

class derived02 : derived01
{

}

class derived01 : baseclass01
{
}

class baseclass01
{
}

etc

You just can''t inherit from multiple base classes (you have to use an
Interface and simply replicate all base classes, like a virtual base
class in C++)

RL


这篇关于奇怪,但C#确实允许多重继承,只要它是串行的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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