TWpf = class(TComponent)
private
function GetPlanetName(const AIndex:integer):string;
function GetPlanetPosition(const APlanetName:string):integer;
FPlanetNames:array[1..9] of string;《《《《编译时此处出错 published
property PlanetName[const AIndex:integer]:string
read GetPlanetName;default;
property PlanetPosition[const APlanetName:string]:integer
read GetPlanetPosition; end;出错提示为[Error] Wpf.pas(43): Field definition not allowed after methods or properties
难道数组不能做为类的一个成员吗??
如果不能,我想实现这种带有数组成员的类该用什么方法??
private
function GetPlanetName(const AIndex:integer):string;
function GetPlanetPosition(const APlanetName:string):integer;
FPlanetNames:array[1..9] of string;《《《《编译时此处出错 published
property PlanetName[const AIndex:integer]:string
read GetPlanetName;default;
property PlanetPosition[const APlanetName:string]:integer
read GetPlanetPosition; end;出错提示为[Error] Wpf.pas(43): Field definition not allowed after methods or properties
难道数组不能做为类的一个成员吗??
如果不能,我想实现这种带有数组成员的类该用什么方法??
TWpf = class(TComponent)
private
FPlanetNames:array[1..9] of string;
function GetPlanetName(const AIndex:integer):string;
function GetPlanetPosition(const APlanetName:string):integer;
published
property PlanetName[const AIndex:integer]:string
read GetPlanetName;default;
property PlanetPosition[const APlanetName:string]:integer
read GetPlanetPosition; end;
constructor TWpf.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FPlanetNames:=('a','b','c','d','e','f','g','h','i');
FProp:=TProp.Create;
end;
可我在对数组初始化时又提示:[Error] Wpf.pas(69): ')' expected but ',' found
可是程序中并没有缺少)号或,号,这又是什么原因?
constructor TWpf.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FPlanetNames:=('a','b','c','d','e','f','g','h','i');<<在此处错误,光标停在'a',后
FProp:=TProp.Create;
end;
可我在对数组初始化时又提示:[Error] Wpf.pas(69): ')' expected but ',' found
可是程序中并没有缺少)号或,号,这又是什么原因?
这种赋值形式是不行的,只能一个一个写
for i:=low(FPlanetNames) to high(FPlanetNames) do
FPlanetNames[i]:=chr(ord('a')+i-1);
有问题请发信息到我的E-mail:[email protected]
有问题请发信息到我的E-mail:[email protected]