Class constants: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Class constants
| Old | New | Line | |
|---|---|---|---|
| 1 | + | FP supports typed class constants, if the compiler-switch | |
| 2 | + | ||
| 3 | + | ``` pascal | |
| 4 | + | {$static on} | |
| 5 | + | ``` | |
| 6 | + | ||
| 7 | + | is set. There are no untyped class constants. | |
| 8 | + | ||
| 9 | + | ``` pascal | |
| 10 | + | type | |
| 11 | + | TCars = class(TVehicles) | |
| 12 | + | private | |
| 13 | + | public | |
| 14 | + | wheelcount: integer; static; | |
| 15 | + | end; | |
| 16 | + | ||
| 17 | + | begin | |
| 18 | + | TCars.wheelcount := 4; | |
| 19 | + | // further assignments are forbidden | |
| 20 | + | end. | |
| 21 | + | ``` | |
| 22 | + | ||
| 23 | + | ## Weblinks | |
| 24 | + | ||
| 25 | + | - [“Static fields”](https://www.freepascal.org/docs-html/ref/refse30.html) in FPC-doc | |
| 26 | + | ||
| 27 | + | --- | |
| 28 | + | *From the Free Pascal wiki, page "Class constants", as it stood on 2018-02-13 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 29 | + | Category: Code | |
| 30 | + | Category: Constants | |
| 31 | + | Category: FPC |
