Class constants: Difference between revisions
From Lazarus wiki
Jump to navigationJump to search
Jwdietrich (talk | contribs) No edit summary |
m (syntaxhighlight, update link to documentation) |
||
Line 1: | Line 1: | ||
FP supports typed class constants, if the compiler-switch | FP supports typed class constants, if the compiler-switch <syntaxhighlight lang="pascal" enclose="none">{$static on}</syntaxhighlight> is set. | ||
<syntaxhighlight lang="pascal"> | |||
{$static on} | |||
</syntaxhighlight> | |||
is set. | |||
There are no untyped class constants. | There are no untyped class constants. | ||
<syntaxhighlight lang="pascal"> | <syntaxhighlight lang="pascal" highlight="5,9-10"> | ||
type | |||
TCars = class(TVehicles) | |||
private | |||
public | |||
wheelcount: integer: static; | |||
end; | |||
begin | |||
TCars.wheelcount := 4; | |||
// further assignments are forbidden | |||
end. | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Weblinks == | == Weblinks == | ||
* [ | * [https://www.freepascal.org/docs-html/ref/refse30.html “Static fields”] in FPC-doc | ||
[[Category:FPC]] | [[Category:FPC]] | ||
[[Category:Constants]] | [[Category:Constants]] |
Revision as of 18:19, 11 February 2018
FP supports typed class constants, if the compiler-switch {$static on}
is set.
There are no untyped class constants.
type
TCars = class(TVehicles)
private
public
wheelcount: integer: static;
end;
begin
TCars.wheelcount := 4;
// further assignments are forbidden
end.
Weblinks
- “Static fields” in FPC-doc