Class constants: Difference between revisions
From Lazarus wiki
Jump to navigationJump to search
Jwdietrich (talk | contribs) No edit summary |
m (add Category:Code) |
||
(2 intermediate revisions by the same user not shown) | |||
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]] | ||
[[Category:Code]] |
Latest revision as of 03:03, 13 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