A
auther
Unregistered / Unconfirmed
GUEST, unregistred user!
程序得部分代码如下:
TDataPoint = class(TObject)
X: Byte
end
TDataList = class(TStringList)
private
{ private declarations }
public
{ public declarations }
destructor Destroy
override
function AddDataPoint(Point: TDataPoint): integer
function GetDataPoint(index: integer): TDataPoint
end
destructor TDataList.Destroy
var
Temp: TObject
begin
while Count <> 0 do
begin
{ make Temp := first Item }
Temp := Objects[0]
{ free it }
Temp.Free
{ delete it }
Delete(0)
end
{ call inherited }
inherited Destroy
end
function TDataList.AddDataPoint(Point: TDataPoint): integer
begin
Result := AddObject('', Point)
end
function TDataList.GetDataPoint(index: integer): TDataPoint
begin
Result := Objects[index] as TDataPoint
end
....
....
..
DataList1:=TDataList.create
DataList2:=TDataList.Create
for i:=1 to 100 do
begin
{ create data object }
P := TDataPoint.Create
P.X := random(1000)
{ add it to the list }
DataList1.AddDataPoint(p)
end
[red]datalist2.Assign(DataList1)
[/red]
最后一句编译时说Access Violation。
请问该如何修改亚。
TDataPoint = class(TObject)
X: Byte
end
TDataList = class(TStringList)
private
{ private declarations }
public
{ public declarations }
destructor Destroy
override
function AddDataPoint(Point: TDataPoint): integer
function GetDataPoint(index: integer): TDataPoint
end
destructor TDataList.Destroy
var
Temp: TObject
begin
while Count <> 0 do
begin
{ make Temp := first Item }
Temp := Objects[0]
{ free it }
Temp.Free
{ delete it }
Delete(0)
end
{ call inherited }
inherited Destroy
end
function TDataList.AddDataPoint(Point: TDataPoint): integer
begin
Result := AddObject('', Point)
end
function TDataList.GetDataPoint(index: integer): TDataPoint
begin
Result := Objects[index] as TDataPoint
end
....
....
..
DataList1:=TDataList.create
DataList2:=TDataList.Create
for i:=1 to 100 do
begin
{ create data object }
P := TDataPoint.Create
P.X := random(1000)
{ add it to the list }
DataList1.AddDataPoint(p)
end
[red]datalist2.Assign(DataList1)
[/red]
最后一句编译时说Access Violation。
请问该如何修改亚。