Nested Type Declarations Type declarations may be nested within class declarations. Nested types are used throughout the .NET framework,
and throughout object-oriented programming in general. They present a way to keep conceptually related types
together, and to avoid name collisions. The same syntax for declaring nested types may be used with the Win32
Delphi compiler.
Declaring Nested Types type
className = class [abstract | sealed] (ancestorType)
memberList
type
nestedTypeDeclaration
memberList
end;
Where nestedTypeDeclaration follows the type declaration syntax defined in Declaring Types.
Nested type declarations are terminated by the first occurance of a non-identifier token, for example, procedure,
class, type, and all visibility scope specifiers.
The normal accessibility rules apply to nested types and their containing types. A nested type can access an instance
variable (field, property, or method) of its container class, but it must have an object reference to do so. A nested
type can access class fields, class properties, and class static methods without an object reference, but the normal
Delphi visibility rules apply.
Nested types do not increase the size of the containing class. In other words, creating an instance of the containing
class does not also create an instance of a nested type. Nested types are associated with their containing classes
only by the context of their declaration.