program Project4;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
type
IBaseInterface =
interface
procedure baseMethod();
end;
IChildInterface1 =
interface(IBaseInterface)
// Stub
end;
IChildInterface2 =
interface(IBaseInterface)
// Stub
end;
TMyObject1 =
class(TInterfacedObject, IChildInterface1)
public procedure baseMethod();
virtual;
abstract;
end;
TMyObject2 =
class(TMyObject1, IChildInterface1, IChildInterface2)
procedure baseForChildInterface1();
procedure baseForChildInterface2();
procedure IChildInterface2.baseMethod = baseForChildInterface1;
procedure IChildInterface1.baseMethod = baseForChildInterface2;
end;
{ TMyObject2 }
procedure TMyObject2.baseForChildInterface1();
begin
WriteLn('
Das ist "baseForChildInterface1()"');
end;
procedure TMyObject2.baseForChildInterface2();
begin
WriteLn('
Das ist "baseForChildInterface2()"');
end;
var
iChild1Reference: IChildInterface1;
iChild2Reference: IChildInterface2;
objRef: TMyObject2;
begin
try
objRef := TMyObject2.Create();
iChild1Reference := objRef;
iChild2Reference := objRef;
iChild1Reference.baseMethod();
iChild2Reference.baseMethod();
except
on E:
Exception do
WriteLn(E.ClassName, '
: ', E.
Message);
end;
readln;
end.