(Gast)
n/a Beiträge
|
AW: Vererbung bei Implementierung eines Interfaces
15. Jul 2018, 14:44
Als weitere Möglichkeit
Delphi-Quellcode:
IMyInterface = interface
['{934A8DAD-87C1-4780-8865-A9BD9CF5DFC8}']
procedure MySharedProcedure;
procedure MyFirstProcedure;
end;
TShared = class
public
procedure MySharedProcedure;
end;
TMyFirstImpl = class(TInterfacedObject, IMyInterface)
private
FShared: TShared;
protected
property Shared: TShared read FShared implements IMyInterface;
procedure MyFirstProcedure;
public
constructor Create;
destructor Destroy; override;
end;
{ TShared }
procedure TShared.MySharedProcedure;
begin
// add some code
end;
{ TMyFirstImpl }
constructor TMyFirstImpl.Create;
begin
inherited;
FShared := TShared.Create;
end;
destructor TMyFirstImpl.Destroy;
begin
FShared.Free;
inherited;
end;
procedure TMyFirstImpl.MyFirstProcedure;
begin
// add some code
end;
|
|
Zitat
|