Difference between revisions of "Class constants"
From Free Pascal wiki
Jump to navigationJump to search (Created page with "FP supports typed class constants, if the compiler-switch <syntaxhighlight lang="pascal"> {$static on} </syntaxhighlight> is set. There are no untyped class constants. <synta...") |
m (add Category:Code) |
||
(4 intermediate revisions by 2 users 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: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