class Car
{
public string description;
private unit nWheels;
static Car(string model,unit nwheels)
{
this.description = description;
this.nWheels = nwheels;
}
static Car(string model)
{
this.description = description;
this.nWheels = 4; }
//etc.
这是书上讲关于从构造函数中调用其他的构造函数(有书可以看下书p86页)这里的model是什么东西啊 怎么在构造函数中又出现了description这个变量了啊 还有unit是什么类型啊~查过MSDN了 都没找到这个东西 看的我云里雾里的 谁能点化下哈~~
description是你在类中声明的一个变量:public string description
uint 是无符号 32 位整数;范围为0 到 4294967295
==
严格地来说是构造函数初始化器
这里的model是什么东西啊 怎么在构造函数中又出现了description这个变量了啊
==
楼主还没明白构造函数的意思,在本例中是使用参数初始化类Car还有unit是什么类型啊
==
无符号整形
可是那个model 你们好像还是没有回答我啊
明明在构造函数的里只有两个参数 一个是 string model,还一个是uint nwheels
那么this.description=description中的description是从哪里冒出来的啊 是不是写错了应该是this.description=model啊?
class 车
{
public string 描述;
private unit 轮子数;
static 车 (string 款式,unit 轮子数)
{
this.描述 = 款式;
this.轮子数= 轮子数;
}
static 车 (string 款式)
{
this.描述= 款式;
this.轮子数= 4; }
} 没看见从构造函数中调用其他的构造函数啊,只不过是重载了构造函数,有2个不同参数的构造函数而已么,第2个车轮数就默认4个了
http://www.wrox.com/WileyCDA/WroxTitle/Professional-C-2005.productCd-0764575341,descCd-ERRATA.html
这是更正的内容
98-99 Error in Text
All instances of
string model
should be
string description