Autor Beitrag
mg80s
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 33

WinXP SP2
Delphi 6 Personal ;) , C# (VS 2003 Prof.)
BeitragVerfasst: Do 06.10.05 00:07 
Hallo zusammen.

Um eine Art Tabellenstruktur zu erstellen, habe ich mir zwei Klassen gebastelt, TRow und TColoumn, also Reihe und Spalte.
In einer Zeile soll zB gespeichert sein ob eine weitere Zeile folgt und ob eine Spalte in der Zeile vorhanden ist. Analog das ganze bei der Spalte. Ausserdem soll in beiden gespeichert werden ob die jeweilige Reihe/Spalte ein Element (Text, Bild) enthält.

Das hatte ich mir so vorgestellt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
type
  TRow = class (TObject)
   private
    NextRow: TRow;
    NextColoumn: TColoumn;
    Element: Pointer;
    width, height: Integer;
  end;
type
  TColoumn = class (TObject)
   private
    NextRow: TRow;
    NextColoumn: TColoumn;
    Element: Pointer;
    width, height: Integer;
  end;


Das Problem dabei ist, dass ja TRow TColoumn braucht und andersrum. Wenn ich TRow nun oben stehem habe, meckert der Compiler aber rum, dass er mit TColoumn nix anfangen kann und andersrum.
Gibt es da einen Trick?
Habe zwar einige OOP-Erfahrungen, versuche es aber das erste mal in Delphi, habt Nachsicht :wink:

Moderiert von user profile iconChristian S.: Zweite Frage entfernt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 06.10.05 00:10 
Hallo!

Du musst eine Forward-Deklaration der zweiten Klasse erstellen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type
  TColumn = class;

type
  TRow = class(TObject)
{... hier weiter wie bisher ...}


Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
mg80s Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 33

WinXP SP2
Delphi 6 Personal ;) , C# (VS 2003 Prof.)
BeitragVerfasst: Do 06.10.05 00:12 
Wow, das ging fix.

Super, danke Dir, die Foreward-Deklaration war mir kein Begriff.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 06.10.05 00:13 
Eine weitere Gelegenheit, Schleichwerbung für meinen Crashkurs Delphi zu machen :mrgreen:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
mg80s Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 33

WinXP SP2
Delphi 6 Personal ;) , C# (VS 2003 Prof.)
BeitragVerfasst: Do 06.10.05 00:37 
Cool, ich glaube, das sollte ich lesen!

Habe mal Deinen Tip versucht, allerdings kommt an der Stelle der Forward-Deklaration:
ausblenden Quelltext
1:
[Error] Unit1.pas(107): Type 'TColoumn' is not yet completely defined					


Hatte dann mal nach Forward-Deklaration gegooglet und bin über das Schlüsselwort "foreward" gestolpert, da kam aber gleich ein Syntaxfehler...
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 06.10.05 01:03 
Liegt wohl daran, dass wir das Wort "column" unterschiedlich schreiben ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
mg80s Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 33

WinXP SP2
Delphi 6 Personal ;) , C# (VS 2003 Prof.)
BeitragVerfasst: Do 06.10.05 01:58 
:D Nee, soweit habe ich schon mitgedacht!

Sieht original so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
type
  TColoumn = class;
type
  TRow = class (TObject)
   private
    NextRow: TRow;
    NextColoumn: TColoumn;
    Element: Pointer;
    width, height: Integer;
  end;
type
  TColoumn = class (TObject)
   private
    NextRow: TRow;
    NextColoumn: TColoumn;
    Element: Pointer;
    width, height: Integer;
  end;


Und wie gesagt obiger Fehler.

Obwogl Du mit Deiner Schreibweise allerdings absolut richtig liegt's wie ich gerade sehe :oops:
Flocke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54

Win 2000, Win XP, Win 2003, Linux
Delphi 2006 Prof.
BeitragVerfasst: Do 06.10.05 08:25 
Du musst einfach nur die types zwischendurch weglassen. Eines oben drüber reicht ja.
mg80s Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 33

WinXP SP2
Delphi 6 Personal ;) , C# (VS 2003 Prof.)
BeitragVerfasst: Do 06.10.05 12:55 
Tatsache, das war's :D

Muss wohl mal dringend meine Delphi-Grundkenntnisse auffrischen :oops:
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: Do 06.10.05 15:49 
Und übrigens:
es heißt nicht "coloumn" sondern "column" :)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 06.10.05 15:53 
user profile iconFlocke hat folgendes geschrieben:
Du musst einfach nur die types zwischendurch weglassen. Eines oben drüber reicht ja.
Lasst Ihr's gelten, wenn ich mich mit der Uhrzeit rausrede? :oops:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
mg80s Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 33

WinXP SP2
Delphi 6 Personal ;) , C# (VS 2003 Prof.)
BeitragVerfasst: Do 06.10.05 16:53 
user profile iconarj hat folgendes geschrieben:
Und übrigens:
es heißt nicht "coloumn" sondern "column" :)


Jup, hatte ich irgendwo falsch aufgeschnappt, ist inzwischen "behoben" :wink:

Und @Christian S.: War dennoch eine großartige und schnelle Hilfe :)