Delphi Error – E2271 Property getters and setters cannot be overloaded

Delphi Compiler Error

E2271 Property getters and setters cannot be overloaded

Reason for the Error & Solution

A property has specified an overloaded procedure as either its getter or setter.

unit Produce;
interface
  type
    Base = class
    public
      function getter : Integer; overload;
      function getter(a : char) : Integer; overload;
      property Value : Integer read getter;
    end;

implementation
function Base.getter : Integer;
begin getter := 0;
end;

function Base.getter(a : char) : Integer;
begin
end;

end.


The overloaded function getter in the above example will cause this error.

unit Solve;
interface
  type
    Base = class
    public
      function getter : Integer;
      property Value : Integer read getter;
    end;

implementation
function Base.getter : Integer;
begin getter := 0;
end;

end.



The only solution when this problem occurs is to remove the offending overload specifications, as is shown in the above example.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...