Delphi Compiler Error
E2131 Class already has a default property
Reason for the Error & Solution
You have tried to assign a default property to a class which already has defined a default property.
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.
The Access property in the code above attempts to become the default property of the class, but Data has already been specified as the default. There can be only one default property in a class.
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.
The solution is to remove the incorrect default property specifications from the program source.