E2136 No definition for abstract method '%s' allowed (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

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.