N
noall
Unregistered / Unconfirmed
GUEST, unregistred user!
先定义:
type
TBaseObject = class(Tobject)
private
FX: Integer;
FY: Integer;
{....}
public
Constructor Create;
destructor Destroy;
override;
property X: Integer read FX write FX;
property Y: Integer read FY write FY;
{....}
end;
type
Tcxbase = class(TList)
private
FTest: Integer;
public
Procedure addObject(NewObject: TBaseObject);
property Test: Integer read FTest write FTest default 0;
end;
在实现中:
constructor TBaseObject.Create;
begin
inherited Create;
Fx:=0;
Fy:=0;
end;
destructor TBaseObject.Destroy;
begin
inherited Destroy;
end;
procedure Tcxbase.addObject(NewObject: TBaseObject);
begin
Add(NewObject);
end;
现在在Click中:
procedure TForm1.Button1Click(Sender: TObject);
Var ph:Tcxbase;
newobject:TBaseObject;
begin
newobject:=TBaseObject.Create;
newobject.X :=1;
newobject.y:=2;
ph.addObject(newobject);//执行到这里时发生了错误,请问是什么原因呢?谢谢
end;
type
TBaseObject = class(Tobject)
private
FX: Integer;
FY: Integer;
{....}
public
Constructor Create;
destructor Destroy;
override;
property X: Integer read FX write FX;
property Y: Integer read FY write FY;
{....}
end;
type
Tcxbase = class(TList)
private
FTest: Integer;
public
Procedure addObject(NewObject: TBaseObject);
property Test: Integer read FTest write FTest default 0;
end;
在实现中:
constructor TBaseObject.Create;
begin
inherited Create;
Fx:=0;
Fy:=0;
end;
destructor TBaseObject.Destroy;
begin
inherited Destroy;
end;
procedure Tcxbase.addObject(NewObject: TBaseObject);
begin
Add(NewObject);
end;
现在在Click中:
procedure TForm1.Button1Click(Sender: TObject);
Var ph:Tcxbase;
newobject:TBaseObject;
begin
newobject:=TBaseObject.Create;
newobject.X :=1;
newobject.y:=2;
ph.addObject(newobject);//执行到这里时发生了错误,请问是什么原因呢?谢谢
end;