Einzelnen Beitrag anzeigen

Benutzerbild von Sprint
Sprint

Registriert seit: 18. Aug 2004
Ort: Edewecht
712 Beiträge
 
Delphi 5 Professional
 
#3

Re: Initialisierung über Stringlist vereben

  Alt 14. Feb 2005, 07:30
Zitat von Flogo:
Das Problem entsteht, wenn ich diese Klasse ableiten und erweitern will
Delphi-Quellcode:
type
  TBase = class(TObject)
  private
    FStringList: TStringList;
    FVariableA: Integer;
    FVariableB: String;
  public
    constructor Create(const FileName: String);
    destructor Destroy; override;
  end;
Delphi-Quellcode:
type
  TDerived = class(TBase)
  private
    FValueC: String;
  public
    constructor Create(const FileName: String);
  end;
Delphi-Quellcode:
constructor TBase.Create(const FileName: String);
begin
  inherited Create;
  FStringList := TStringList.Create;
  with FStringList do
  begin
    LoadFromFile(FileName);
    FVariableA := StrToInt(Values['VarA']);
    FVariableB := Values['VarB'];
  end;
end;

destructor TBase.Destroy;
begin
  FStringList.Free;
  inherited;
end;
Delphi-Quellcode:
constructor TDerived.Create(const FileName: String);
begin
  inherited;
  FValueC := FStringList.Values['VarC'];
end;
Ciao, Sprint.

"I don't know what I am doing, but I am sure I am having fun!"
  Mit Zitat antworten Zitat