将阶级作为财产的优势 [英] advantages of making class as property
本文介绍了将阶级作为财产的优势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将类设为财产的好处?
advantages of making class as property?
class Emp{
p int Id;
p String Ename;
}
class SomeCls
{
public Emp emp; -> people are using class as property.
}
推荐答案
您的示例根本不使用属性.它只是声明(在Emp情况下可能是公开的)字段,并让其他分类继续进行下去.
EMP类实例嵌入在SomeClass实例中,但是不能通过属性访问-它是一个公共字段.这不是一个好主意!
Your example does not use a property at all. It just declares (presumably public in the case of Emp) fields and lets other cl;asses get on with it.
The EMP class instance is embedded within the SomeClass instance, but it is not accessed via a property - it is a public field. This is not a good idea!
这篇关于将阶级作为财产的优势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文