Autor Beitrag
winx
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 249



BeitragVerfasst: Di 26.07.05 08:01 
Hi,

gibt es eine Möglichkeit (außer im Konstruktor) eine Variable schon zu beginn in einer Klasse zu initialisieren?

Sowas wie

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type
  TKlasse = class
     private
      aString : string = 'Hallo Welt';
     public
     end;


Danke,
nlw

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
FaTaLGuiLLoTiNe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 5

Windows 7, Windows 8.1
Delphi XE
BeitragVerfasst: Di 26.07.05 08:20 
Hast du den von da von dir geposteten Code einfach mal ausprobiert. Das sollte meiner Meinung nach schon klappen. Nur lokale Variablen kann man AFAIK nicht bei der Deklaration initialisieren.

_________________
<< FaTaLGuiLLoTiNe >>
Rhinoceroses don't play games!
winx Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 249



BeitragVerfasst: Di 26.07.05 08:25 
hab ich, kam aber ein Compiler Fehler :(
FaTaLGuiLLoTiNe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 5

Windows 7, Windows 8.1
Delphi XE
BeitragVerfasst: Di 26.07.05 08:34 
Hmm hast wohl recht, in der Klassendeklaration funktioniert es echt nicht. Hatte ich falsch in Erinnerung. Da bleibt dir wohl doch nur der Konstruktor (aber dafür ist er ja unter anderem schliesslich auch da).

_________________
<< FaTaLGuiLLoTiNe >>
Rhinoceroses don't play games!