1.接口的继承者必须实现所有定义的接口函数或者方法
IMyInterface1 = interface(IInterface)
['{63E072DF-B81E-4734-B3CB-3C23C7FDA8EA}']
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
procedure ShowMSG;
end;
如果TMyInterface = class(TObject, IMyInterface1)
则在类TMyInterface 中许实现所有的QueryInterface,_AddRef,_Release,ShowMSG。
2.当继承多个接口的时候,如果有同样的函数名称,可以通过不同的名称进行区分
IMyInterface1 = interface(IInterface)
['{63E072DF-B81E-4734-B3CB-3C23C7FDA8EA}']
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
procedure ShowMSG;
end;
IMyInterface2 = interface(IInterface)
['{9DF6FD12-E8FB-4500-9E43-36C6E769F199}']
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
procedure ShowMSG;
end;
TMyInterface = class(TObject, IMyInterface1, IMyInterface2)
private
FRefCount: Integer;
FMsg: string;
public
procedure IMyInterface1.ShowMSG = ShowMSG1;
procedure IMyInterface2.ShowMSG = ShowMSG2;
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
procedure ShowMSG1;
procedure ShowMSG2;
end;