tsomeobj=class
private
fcount:integer;
protected
procedure setcount(value:integer);
published
property count:integer read fcount write setcount default 0;//属性定义
end;
该属性从私有成员fcount读出值,而靠setcount方法设置值到私有成员fcount。
属性的优势在于可以很直观进行读写,而又不同于私有成员。因为属性可以通过写访问方法来保护私有成员:
procedure tsomeboj.setcount(value:integer);
begin
if fcount<>value then
fcount:=value;
end;