Delphi Error – E2136 No definition for abstract method ‘%s’ allowed

Delphi Compiler Error

E2136 No definition for abstract method ‘%s’ allowed

Reason for the Error & Solution

You have declared <name> to be abstract, but the compiler has found a definition for the method in the source file. It is illegal to provide a definition for an abstract declaration.

program Produce;

  type
    Base = class
      procedure Foundation; virtual; abstract;
    end;

    procedure Base.Foundation;
    begin
    end;

begin
end.

Abstract methods cannot be defined. An error will appear at the point of Base.Foundation when you compile this program.

program Solve;

  type
    Base = class
      procedure Foundation; virtual; abstract;
    end;

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

    procedure Derived.Foundation;
    begin
    end;

begin
end.

Two steps are required to solve this error. First, you must remove the definition of the abstract procedure which is declared in the base class. Second, you must extend the base class, declare the abstract procedure as an ‘override’ in the extension, and then provide a definition for the newly declared procedure.

Share:

Leave A Reply

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

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...