Delphi Error – E2147 Property ‘%s’ does not exist in base class

Delphi Compiler Error

E2147 Property ‘%s’ does not exist in base class

Reason for the Error & Solution

The compiler believes you are attempting to hoist a property to a different visibility level in a derived class, but the specified property does not exist in the base class.

program Produce;

  type
    Base = class
    private
      a : Integer;
      property BaseProp : integer read a write a;
    end;

    Derived = class (Base)
      ch : Char;
      property Alpha read ch write ch; (*case 1*)
      property BesaProp; (*case 2*)
    end;

begin
end.

There are two basic causes of this error. The first is the specification of a new property without specifying a type; this usually is not supposed to be a movement to a new visibility level. The second is the specification of a property which should exist in the base class, but is not found by the compiler; the most likely cause for this is a simple typo (as in “BesaProp”). In the second form, the compiler will also output errors that a read or write clause was expected.

program Solve;

  type
    Base = class
    private
      a : Integer;
      property BaseProp : integer read a write a;
    end;

    Derived = class (Base)
      ch : Char;
    public
      property Alpha : Char read ch write ch; (*case 1*)
      property BaseProp; (*case 2*)
    end;

begin
end.

The solution for the first case is to supply the type of the property. The solution for the second case is to check the spelling of the property name.

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...