问题描述
我知道这并没有太多的背景,但是,在这里(取自
Petzold'用C#编程Windows)片段:
class DatePlus:Date
{
public DatePlus(){}
public DatePlus(int year,int month,int day ):基地(年,月,
天){}
..
..
..
}
我理解DatePlus(){}的默认构造函数。关于第二个,我的问题是
。它是说DatePlus在它的
正式构造函数中接受一年,一个月和一天,但随后立即将它们传递给它继承的基类(日期) ?
谢谢。
它将它们传递给Date中的base *构造函数*。请注意,
构造函数本身并不是在DatePlus中继承的。
-
Jon Skeet - < sk * **@pobox.com>
如果回复小组,请不要给我发邮件
是的。
-
Jon Skeet - < sk *** @ pobox.com>
如果回复小组,请不要给我发邮件
I know this doesn''t have much of a context, but, in this (take from
Petzold''s Programming Windows with C#) snippet:
class DatePlus: Date
{
public DatePlus(){}
public DatePlus(int year, int month, int day): base(year, month,
day){}
..
..
..
}
I understand the default constructor for DatePlus(){}. My question is
about the second one. Is it saying that DatePlus accepts, in its
formal constructor a year, month and day, but then immediately passes
them to the base class that it inherited from (Date)?
Thank you.
It passes them to the base *constructor* in Date. Note that the
constructor itself isn''t inherited in DatePlus.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Yes.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
这篇关于实例和继承问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!