Autor Beitrag
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: So 28.10.07 12:16 
Morgen zusammen :)

nächste Frage:

Ich habe zwei Klassen, die sich gegenseitig verwenden.
Gibt es eine Möglichkeit eine der Klasse ganz am anfang als forward zu deklarieren?

Wenn das nicht geht, mache ich eine "Custom-Klasse" (Vorgängerklasse), die eben noch nicht die andere Klasse verwendet...

Danke schon mal!
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 28.10.07 12:28 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
type

  TKlasse1 = class;

  TKlasse2 = class
    Klasse1: TKlasse1;
  end;

  TKlasse1 = class
    Klasse2: TKlasse2;
  end;


Geht nur innerhalb desselben type-Blocks. Wenn dazwischen z.B. noch ein Const ist, geht's nicht.
Jakob Schöttl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: So 28.10.07 13:31 
oh, das geht leider nicht user profile icondelfiphan:
ausblenden Quelltext
1:
[Pascal Fehler] Polynome.pas(69): E2004 Bezeichner redefiniert: 'TNichtRationalPolynom'					


und der quelltext sieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
type
  TNichtRationalPolynom = class(TObject);

  TPolynom = class(TObject)
    function PolynomDivision(PolynomDivisor: TPolynom; var Rest: TNichtRationalPolynom): TPolynom;
  end;

  TNichtRationalPolynom = class(TObject)
  private
    FZaehler: TPolynom;
    FNenner: TPolynom;
  end;
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 28.10.07 15:18 
Ohne (TObject). Der Compiler muss dort lediglich wissen, dass es eine Klasse ist.
ausblenden Delphi-Quelltext
1:
TNichtRationalPolynom = class;					
Jakob Schöttl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: So 28.10.07 15:46 
siehe da, es geht *freu*

Vielen Dank delfiphan, ich dachte du hast nur class geschrieben weil class und class(TObject) ja normalerweise das gleiche sind...