Delphi Error – E2267 Previous declaration of ‘%s’ was not marked with the ‘overload’ directive

Delphi Compiler Error

E2267 Previous declaration of ‘%s’ was not marked with the ‘overload’ directive

Reason for the Error & Solution

There are two solutions to this problem. You can either remove the attempt at overloading or you can mark the original declaration with the overload directive. The example shown here marks the original declaration.

program Produce;
type
  Base = class
    procedure func(a : integer);
    procedure func(a : char); overload;
  end;

  procedure Base.func(a : integer);
  begin
  end;

  procedure Base.func(a : char);
  begin
  end;

end.

This example attempts to overload the char version of func without marking the first version of func as overloadable.

You must mark all functions to be overloaded with the overload directive. If overload were not required on all versions it would be possible to introduce a new method which overloads an existing method and then a simple recompilation of the source could produce different behavior.

program Solve;
type
  Base = class
    procedure func(a : integer); overload;
    procedure func(a : char); overload;
  end;

  procedure Base.func(a : integer);
  begin
  end;

  procedure Base.func(a : char);
  begin
  end;

end.

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