Delphi - 接口和重载指令
我对 Delphi 的接口有点困惑,所以我问你这个问题。接口可以与抽象类“关联”。 (它不实现在其上声明的方法。)在其上声明的所有方法都在正在实现该接口的类中实现。
那么,为什么允许在接口的方法声明上使用重载指令呢?
type
IFoo = interface
function Test : String; overload;
end;
编译器对此保持沉默。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
重载
允许在单个类/接口中具有几个相同的命名方法,但具有不同的参数集。Test
方法。使用这个单一方法就不需要重载
。但如果需要,您可以引入具有不同参数集的附加Test
方法。override
指令......overloaded
allows to have few the same named methods, but with different parameter sets, in a single class / interface.Test
method. With this single method there is no need foroverloaded
. But you can introduce, if you need, additionalTest
methods with differrent parameter sets.override
directive ...