Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Record als Konstante (https://www.delphipraxis.net/26738-record-als-konstante.html)

Giantics 28. Jul 2004 13:38


Record als Konstante
 
Gibt es eine Möglichkeit, einem Record bei der Deklaration gleich einen Wert zuzuweisen?

Ich hab das mal anhand eines TPoints probiert, habe es aber nicht hinbekommen. :cry:
Delphi-Quellcode:
const InsertPos: TPoint=(10,10); // geht nicht
const InsertPos = (10,10); // geht nicht
const InsertPos = TPoint(10,10); // geht nicht
const InsertPos: TPoint= [10,10]; // geht nicht
const InsertPos = [10,10]; // ist kein TPoint
bei C++ würde das so funkionieren:
Code:
const TPoint InsertPos={10,10};
Wer weiß Rat?

NicoDE 28. Jul 2004 13:42

Re: Record als Konstante
 
Delphi-Quellcode:
const
  Foo: TPoint = (
    X: 10;
    Y: 10
  );

Giantics 28. Jul 2004 13:44

Re: Record als Konstante
 
Danke, das habe ich gesucht. :-D

sakura 28. Jul 2004 13:55

Re: Record als Konstante
 
@Giantics: Setze oben bitte noch die [delphi]-Tags

...:cat:...


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:51 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz