Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Konstruktor erstellen (https://www.delphipraxis.net/140667-konstruktor-erstellen.html)

martin_ 23. Sep 2009 11:56


Konstruktor erstellen
 
Hallo,
habe folgende Frage:
Delphi-Quellcode:
 
  TClassA = class (TObject)
  private
    a : string;
  public
    constructor create (ValueA : string);
  end;

  TClassB = class (TClassA)
  private
    b : string;
  public
    constructor create (ValueB : string);
  end;
Nun möchte ich wenn ein Exemplar von TClassB erstellt wird ein Aufruf von TClassB.Create(ValueA,ValueB) erstellt wird. Dh. die Werte von ValueA + ValueB im Konstruktor zuweisen.

himitsu 23. Sep 2009 12:01

Re: Konstruktor erstellen
 
Delphi-Quellcode:
TClassA = class (TObject)
  private
    a : string;
  public
    constructor create (ValueA : string);
  end;

  TClassB = class (TClassA)
  private
    b : string;
  public
    constructor create (ValueA, ValueB : string);
  end;


constructor TClassB.create (ValueA, ValueB : string);
begin
  inherited Create(ValueA);
  ...
end;

mkinzler 23. Sep 2009 12:01

Re: Konstruktor erstellen
 
Delphi-Quellcode:
TClassB = class (TClassA)
  private
    b : string;
  public
    constructor Create(ValueA, ValueB : string);
end;

constructor TClassB.Create (ValueA, ValueB : string);
begin
    inherited Create( ValueA);
    b := ValueB;
end;

martin_ 23. Sep 2009 12:08

Re: Konstruktor erstellen
 
Danke, ich glaube ich sollte eine Pause machen um wieder produktiv zu sein...


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:50 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz