E2131 クラスはすでにデフォルトプロパティを持っています (Delphi)
エラーと警告のメッセージ(Delphi) への移動
デフォルトプロパティをすでに定義してあるクラスに対してデフォルトプロパティを割り当てようとしました。
program Produce; 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; property Access[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.
{ このコードでは Access プロパティをこのクラスのデフォルトプロパティにしようとしているが,すでに Data がデフォルトとして指定済みである。デフォルトプロパティは 1 つのクラスに 1 つだけである }
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.
{ プログラムのソースから正しくないデフォルトプロパティの指定を削除すれば解決する }