E2137 Method '%s' not found in base class (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)

You have applied the 'override' directive to a method, but the compiler is unable to find a procedure of the same name in the base class.


program Produce;

  type
    Base = class
      procedure Title; virtual;
    end;

    Derived = class (Base)
      procedure Titl; override;
    end;

    procedure Base.Title;
    begin
    end;

    procedure Derived.Titl;
    begin
    end;

begin
end.

A common cause of this error is a simple typographical error in your source code. Make sure that the name used as the 'override' procedure is spelled the same as it is in the base class. In other situations, the base class will not provide the desired procedure: it is those situations which will require much deeper analysis to determine how to solve the problem.


program Solve;

  type
    Base = class
      procedure Title; virtual;
    end;

    Derived = class (Base)
      procedure Title; override;
    end;

    procedure Base.Title;
    begin
    end;

    procedure Derived.Title;
    begin
    end;

begin
end.

The solution (in this example) was to correct the spelling of the procedure name in Derived.