Autor Beitrag
Xong
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 113

WIN 2000
Borland Developer Studio 2006
BeitragVerfasst: Fr 25.01.08 12:45 
Hallo Forümmler!

Ich habe eine Beispielklasse:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
TClass = class
  private
    [...]
  public
    Attribut1: Typ;
    Attribut2: Typ;
    Attribut3: Typ;
    Attribut4: Typ;
    Attribut5: Typ;
    Attribut6: Typ;

    constructor Create;
    [...]
end;

[...]

constructor TClass.Create;
begin
  { while Attribut <> nil do begin
      Initialisiere(Attribut);
      NextAttribut;
    end; }

end;

Nun kommt es immer wieder vor, dass ich neue Attribute einfügen muss.

Damit ich nicht immer alle/einige Methoden der Klasse umschreiben muss, wäre es praktisch, wenn es eine Funktion gäbe, mit der ich zumindest auf jedes Attribut in einer Schleife zugreifen könnte.
Ist so etwas möglich?

Danke für Hilfe,
Xong
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Fr 25.01.08 13:19 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
FAttr: array[0..??] of Typ

property Attr[const AIndex: Integer]: Typ read GetAttr write SetAttr;

function GetAttr(const AIndex: Integer): Typ;
begin
  Result := FAttr[AIndex];
end;

procedure SetAttr(const AIndex: Integer; Value: Typ);
begin
  FAttr[AIndex] := Value;
end;

zBsp so

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!