複数のポリゴンを TFPolygon = この TObjectList 内の TPoint の配列として格納する Objectlist を定義しました。しかし、私のオブジェクトリストの追加機能を使用すると、アクセス違反エラーが発生します:
type
TFPolygon = array of TPoint;
TFPolygonList = class(TObjectList)
private
procedure SetPolygon(Index: Integer; Value: TFPolygon);
function GetPolygon(Index: Integer): TFPolygon;
public
procedure Add(p: TFPolygon);
property Items[index: Integer]: TFPolygon read GetPolygon write SetPolygon; default;
end;
implementation
procedure TFPolygonList.SetPolygon(Index: Integer; Value: TFPolygon);
begin
inherited Items[Index] := Pointer(Value);
end;
function TFPolygonList.GetPolygon(Index: Integer): TFPolygon;
begin
Result := TFPolygon(inherited Items[Index]);
end;
procedure TFPolygonList.Add(p: TFPolygon);
begin
inherited Add(Pointer(p));
end;
このコード サンプル内のエラーを理解できませんか? クラスを TObjectList 内にのみ格納できますか、それとも TPoints の配列を格納する方法も有効ですか?