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.