【发布时间】:2016-05-18 09:35:27
【问题描述】:
在 Delphi Seattle 10 中,我尝试使用 implements 关键字委托接口的实现,但是当从第一个接口派生的接口也包含在类声明中时,不接受委托。
以下代码的编译失败,并显示“缺少接口方法 IInterface1.DoSomethingFor1 的实现”消息。如果我从类声明中删除 IInterface2,则代码会编译。如果我从其他东西派生 IInterface2,那么 IInterface1 它也会编译。
我做错了什么?或者我怎样才能做到这一点?
type
IInterface1 = interface(IInterface)
['{03FB3E2E-C0DD-4E17-B6CD-D333E1E7255E}']
procedure DoSomethingFor1;
end;
Iinterface2 = interface(IInterface1)
['{89C266E2-2816-46AD-96AA-DD74E78A4D1E}']
end;
T1 = class(TInterfacedObject, IInterface1, IInterface2)
private
Fi1: IInterface1;
public
property I1_Delegate: IInterface1 read Fi1 implements IInterface1;
end;
【问题讨论】:
-
以及那些有 exact 重复的 :) 答案也解释了编译器要求派生接口的实现也需要实现(而不是委托)的原因) 的任何基本接口。
标签: delphi