作业帮 > 综合 > 作业

publice class Sample {private Sample means;}在Sample类的定义中引用Sa

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/10 08:20:37
publice class Sample {private Sample means;}在Sample类的定义中引用Sample的类型变量如何去理解?
不是在定义完一个类后才可以声明那种类型的变量吗?
publice class Sample {private Sample means;}在Sample类的定义中引用Sa
publice class Sample
{
private static Sample _means= null; //定义Sample类型的变量 _means
public static Sample Means
{
get
{
return _means; //在Sample类的定义中引用Sample的类型变量
}
private set
{
_means= value;
}
}
static Sample ()
{
_means= new Sample (); //静态构造函数,实例化一个Sample类
}
}