E2132 デフォルトプロパティは配列型プロパティでなければなりません (Delphi)

提供: RAD Studio
移動先: 案内検索

エラーと警告のメッセージ(Delphi) への移動

クラスに指定したデフォルトプロパティが配列プロパティではありません。デフォルトプロパティは配列プロパティでなければなりません。


program Produce;

  type
    Base = class
      function GetV : Char;
      procedure SetV(x : Char);

      property Data : Char read GetV write SetV; default;
    end;

  function Base.GetV : Char;
  begin GetV := 'A';
  end;

  procedure Base.SetV(x : Char);
  begin
  end;

begin
end.

{ デフォルトプロパティは,配列型でなければならない。このコードの Data プロパティは配列型でなく Char 型を指定している }


program Solve;

  type
    Base = class
      function GetV(i : Integer) : Char;
      procedure SetV(i : Integer; const x : Char);

      property Data[i : Integer] : Char read GetV write SetV; default;
    end;

  function Base.GetV(i : Integer) : Char;
  begin GetV := 'A';
  end;

  procedure Base.SetV(i : Integer; const x : Char);
  begin
  end;

begin
end.

{ エラーを起こしたプロパティの指定を配列型に変更するか,default 指令を削除すればこのエラーはなくなる }