![]() |
Prototyp einer Klasse erstellen
Hi, ist es möglich in Delphi einen Prototyp einer Klasse zu erstellen. Grund ist ich will folgendes realisieren:
Delphi-Quellcode:
Natürlich ist TClass2 in TClass1 nicht bekannt und umgekehrt. Daher meine Frage:
type TClass1 = class(TObject)
public a:TClass2; end; type TClass2 = class(TObject) public b:TClass1; end; Ist es möglich, dass ich vor die Definition von TClass1 noch einen Klassenprototyp von TClass2 schreibe? z.B. so:
Delphi-Quellcode:
Danke für eure Hilfe :)
type TClass1;
|
Re: Prototyp einer Klasse erstellen
Steht hier im Forum glaube mehrere hunderte Male :zwinker:
Delphi-Quellcode:
Edit: Hier noch ein interessanter Link für dich:
// Korrigierte Fassung...
type TClass2 = class; // Fehler: Hier war das "(TObject)" zu viel TClass1 = class(TObject) public a:TClass2; end; TClass2 = class(TObject) public b:TClass1; end; ![]() Korrektur des Quelltextes, sodass es hier nun auch richtig steht. |
Re: Prototyp einer Klasse erstellen
Da bekomm ich beim dritten Typ einen "Identifier redeclared"... Ist das in Delphi7 schon möglich?
|
Re: Prototyp einer Klasse erstellen
Zitat:
Delphi-Quellcode:
So ist es falsch, bzw. gibt einen Fehler
type
TFoo1 = class; TFoo2 = class Foo1 := TFoo1; end; TFoo1 = class Foo2 : TFoo2; end;
Delphi-Quellcode:
So hat s.h.a.r.k das ja auch geschrieben, aber nicht explizit drauf hingewiesen ;)
type
TFoo1 = class; type TFoo2 = class Foo1 := TFoo1; end; type TFoo1 = class Foo2 : TFoo2; end; |
Re: Prototyp einer Klasse erstellen
Ich hatte das (TObject) zu viel. Das hat man davon, dass der Firefox nicht automatisch den Quelltext, den man hier schreibt, compiliert :mrgreen:
|
Re: Prototyp einer Klasse erstellen
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:12 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz