Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi - Interfaces and overload directive

I'm a little bit confused on interfaces in Delphi, so I'm asking you about this. An interface can be 'associated' with an abstract class. (It does not implement the methods declared on it.) All the methods declared on it are implemented in the class/classes which is/are implementing the interface.

So, why then is it allowed to have the overload directive on the method declaration of an interface?

type 
 IFoo = interface
  function Test : String; overload;
 end;

Compiler is quiet on this.

like image 514
RBA Avatar asked Dec 27 '22 12:12

RBA


1 Answers

  1. overloaded allows to have few the same named methods, but with different parameter sets, in a single class / interface.
  2. Your interface has Test method. With this single method there is no need for overloaded. But you can introduce, if you need, additional Test methods with differrent parameter sets.
  3. Probably you are thinking about override directive ...
like image 150
da-soft Avatar answered Dec 30 '22 11:12

da-soft