Einzelnen Beitrag anzeigen

Dax
(Gast)

n/a Beiträge
 
#22

Re: Basisklasse und davon abgeleitet drei Standardklassen

  Alt 8. Okt 2007, 21:16
Delphi-Quellcode:
type
  IStartwert = interface
    function GibStartwert: string;
  end;

  TStartwert = class(TInterfacedObject, IStartwert)
  private
    fStartwert: string;
  public
    function GibStartwert: string;

    constructor Create(startwert: string);
  end;

  TEditEx = class(TEdit, IStartwert)
  private
    fStartwert: TStartwert;
  public
    property Startwert: IStartwert read fStartwert implements IStartwert;

    constructor Create;
  end;


function TStartwert.GibStartwert: string;
begin
  Result := fStartwert;
end;

constructor TStartwert.Create(startwert: string);
begin
  inherited Create;
  fStartwert := startwert;
end;

constructor TEditEx.Create;
begin
  inherited Create;
  fStartwert := TStartwert.Create('blubb');
end;
Ich weiß nicht, ob es direkt kopiert so funktioniert (hab kein Delphi, es zu testen), aber im Prinzip dürfte das doch deinen Anforderungen entsprechen..?
  Mit Zitat antworten Zitat