闷
闷闷
Unregistered / Unconfirmed
GUEST, unregistred user!
program ImplementInterface
type
IMyInterface = interface
procedure P1
procedure P2
end
TMyImplClass = class
procedure P1
procedure P2
end
TMyClass = class(TInterfacedObject, IMyInterface)
FMyImplClass: TMyImplClass
property MyImplClass: TMyImplClass read FMyImplClass implements IMyInterface
end
procedure TMyImplClass.P1
begin
WriteLn('P1')
end
procedure TMyImplClass.P2
begin
WriteLn('P2')
end
var
MyClass: TMyClass
MyInterface: IMyInterface
begin
MyClass := TMyClass.Create
MyClass.FMyImplClass := TMyImplClass.Create
MyInterface := MyClass
MyInterface.P1;
MyInterface.P2;
ReadLn
end.
type
IMyInterface = interface
procedure P1
procedure P2
end
TMyImplClass = class
procedure P1
procedure P2
end
TMyClass = class(TInterfacedObject, IMyInterface)
FMyImplClass: TMyImplClass
property MyImplClass: TMyImplClass read FMyImplClass implements IMyInterface
end
procedure TMyImplClass.P1
begin
WriteLn('P1')
end
procedure TMyImplClass.P2
begin
WriteLn('P2')
end
var
MyClass: TMyClass
MyInterface: IMyInterface
begin
MyClass := TMyClass.Create
MyClass.FMyImplClass := TMyImplClass.Create
MyInterface := MyClass
MyInterface.P1;
MyInterface.P2;
ReadLn
end.