delphi中TObjectList的使用

delphi中TObjectList的使用

TObjectList represents an ordered list of objects, accessible by an index. 

TObjectList is a TList with the capability of automatically freeing object entries when they are removed from the list. When a TObjectList is instantiated, an AOwnsObjects parameter specifies whether the list owns the list entries. If the entry is owned, when the entry object is removed from the list, the entry object is freed. 

The OwnsObjects property gets or sets the object ownership.  

这是官网上的一段原话,意思是:TObjectList属于TList,但不同的是,TObjectList有自动释放对象的能力,当这些对象呗删除时。而这个功能取决于AOwnsObjects变量,如果这些输入属于list它自己,那么当这些输入对象呗删除后,也就自动释放这些输入对象。

发表评论

电子邮件地址不会被公开。 必填项已用*标注