为什么Tlist可以这样用?
type
tt=class
name:string;
end;
begin
list:=tlist.create;
list.capacity:=10;
att:=tt.create;
list.add(att);
tt(list[0]).name:='beta'//为什么可以象数组那样访问那些指针?
...............
end.我看过Tlist的源码,没有发现特别的property或者method。
list[0]和list.items[0]效果是一样的,但是我没有在相关的
文档里找到这种用法的说明。
怎么回事哪?
type
tt=class
name:string;
end;
begin
list:=tlist.create;
list.capacity:=10;
att:=tt.create;
list.add(att);
tt(list[0]).name:='beta'//为什么可以象数组那样访问那些指针?
...............
end.我看过Tlist的源码,没有发现特别的property或者method。
list[0]和list.items[0]效果是一样的,但是我没有在相关的
文档里找到这种用法的说明。
怎么回事哪?
TList=class(TObject)
.........
property Items[Index: Integer]: Pointer read Get write Put;default;
.........
end;
Items是TList的默认属性,可以那样简写。