我的类的定义如下:
TMyClass_New = class(TObject)
private
{ Private declarations }
function GetItems (Index: integer): TMyClass;
procedure SetItems(Index: integer; const Value: TMyClass);
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Items[Index: integer]:TMyClass read GetItems write SetItems;
end;报错:
"Published property 'Items' cannot be of type ARRAY".但delphi的TList中的Items属性就是这么定义的.我的为什么不行?
TMyClass_New = class(TObject)
private
{ Private declarations }
function GetItems (Index: integer): TMyClass;
procedure SetItems(Index: integer; const Value: TMyClass);
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Items[Index: integer]:TMyClass read GetItems write SetItems;
end;报错:
"Published property 'Items' cannot be of type ARRAY".但delphi的TList中的Items属性就是这么定义的.我的为什么不行?
再请问兄台一句,public和published有什么区别?
TMyClass_New = class(TObjectList)
你试试!
Published 表示是公开的,当你把这个类做成组件的时候,在Published中定义的属性会出现在
Delphi的属性窗口中。