Nested Constants Constants can be declared in class types in the same manner as nested type sections. Constant sections are
terminated by the same tokens as nested type sections (i.e. reserved words or visibility specifiers). Typed constants
are not supported, so you cannot declare nested constants of value types, such as Currency, or TDateTime.
Nested constants can be of any simple type: ordinal, ordinal subranges, enums, strings, and real types.
The following code demonstrates the declaration of nested constants:
type
TMyClass = class
const
x = 12;
y = TMyClass.x + 23;
procedure Hello;
private
const
s = 'A string constant';
end;
begin
writeln(TMyClass.y); // Writes the value of y, 35.
end.
168