Autor Beitrag
Astraios
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 25



BeitragVerfasst: Do 15.09.05 10:03 
Hallo,

ich hab da mal eine grundlegende Frage, zu der ich mit der Suche leider keine Antwort gefunden habe:

Ich baue mir eine Klassenstruktur auf.
Dabei Enthält eine Klasse ein Objekt einer anderen Klasse. Diese soll dann aber ne Referenz auf die erste Klasse enthalten (als Parent)...

Das sieht dann ungefähr so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
  TFenster = class (TObject)
  private
  ...
  public
  constructor Create(AParent: THaus);
  property Parent: THaus;
  end;

  THaus = class (TObject)
  private
    ...
  public
    constructor Create(AParent: TStrasse);
    ...
    property Fenster: TFenster;
    property Parent: TStrasse;
  end;


Soll heißen: In der Klasse TFenster bräucht ich schon den Typ "THaus" für die "Parent"-property. Wenn ich die Klassen in umgekehrter Reihenfolge schreib, bringt das auch nichts, weil ich ja "TFenster" auch in THaus brauch...
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Do 15.09.05 10:12 
Hallo,

wie folgt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  THaus=class// Vorwärtsdeklaration

  TFenster = class (TObject)  
    ...
  end;  

 
  THaus = class (TObject)  
   ...
  end;

Näheres dazu in der Delphi-Hilfe.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Astraios Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 25



BeitragVerfasst: Do 15.09.05 12:00 
Hm... da hätt ich ja auch selbst drauf kommen können (bzw. sollen) :oops:

Danke!
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Fr 24.03.06 13:43 
Hallo, ich habe ein ganz ähnliches Problem aber komm nicht drauf, was ich falsch gemacht haben könnte :cry:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
type
  //forward declarations
  TFile = class;
  TFolderList = class;
  TFolder = class;

  TSoftwareRequirement = class(TFolder)
  private
  ...
  end;  
  TFolder = class(TFolderList)
    private
      fEnabled:boolean;
  ...
  end;
end;

Herr Gott, mittags zu coden sollte verboten werden :roll: Sauber dklariert, sauber vorwärtsdeklariert aber ich bekomme trotzdem
Zitat:
[Fehler] CompareGlobal.pas(13): Typ 'TFolder' ist nicht vollständig definiert
Grendel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 443

Gentoo Linux, MacOS X, Win 2000
D5 Ent, D7 Ent, Lazarus, Anjuta, MonoDevelop
BeitragVerfasst: Fr 24.03.06 14:08 
Du hast die Klasse TFolderList nirgendwo vollständig deklariert.

Bis neulich ...
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Do 30.03.06 12:31 
Ups vergessen mit einzufügen, stand aber darunter *schwör* :D

Das Problem war trotzdem da, ich konnte es durch Umstellen der normalen Deklarationen in zwischen lösen. Trotzdem Danke!