{多级接口实现方法 }
{DateTime:2013.11.7}
iFace = interface
['{68252415-0850-4B0D-89B5-C7F41C1E13F1}']
function getFuc: string;
procedure Msg;
end;
iBace = interface
['{607028C1-69BD-4FCA-A8F2-1A7051D236AD}']
function GetFuc: integer;
procedure Msg;
end;
Tface = class(TInterfacedObject, iFace, iBace)
public
{ DONE : 设定别名 }
function iFace.getFuc = iface_getFuc;
procedure iFace.Msg = iface_Msg;
function iBace.GetFuc = ibace_GetFuc;
procedure iBace.Msg = iBace_Msg;
{ DONE : 重新命名 }
function iface_getFuc: string;
function ibace_GetFuc: integer;
procedure iface_Msg;
procedure iBace_Msg;
end;
{ Tface }
function Tface.ibace_GetFuc: integer;
begin
Result := 0;
end;
procedure Tface.iBace_Msg;
begin
ShowMessage('iBace_Msg');
end;
function Tface.iface_getFuc: string;
begin
Result := 'iface_GetFuc';
end;
procedure Tface.iface_Msg;
begin
ShowMessage('iface_Msg');
end;
procedure TForm1.Button1Click(Sender: TObject); //调用
var
Ta: Tface;
begin
mmo1.Lines.Clear;
try
Ta := Tface.Create;
mmo1.Lines.Add('iface_getFuc: ' + Ta.iface_getFuc);
mmo1.Lines.Add('iBace_getFuc: ' + format('%d', [Ta.ibace_GetFuc]));
Ta.iface_Msg;
Ta.iBace_Msg;
finally
FreeAndNil(Ta);
end;
end;