Quick start manual
Classes and objects
7-5
Class types
You can increase the visibility of a member in a descendant class by redeclaring it,
but you cannot decrease its visibility. For example, a protected property can be made
public in a descendant, but not private. Moreover, published members cannot
become public in a descendant class. For more information, see “Property overrides
and redeclarations” on page 7-23.
Private, protected, and public members
A private member is invisible outside of the unit or program where its class is
declared. In other words, a private method cannot be called from another module,
and a private field or property cannot be read or written to from another module. By
placing related class declarations in the same module, you can give the classes access
to one another’s private members without making those members more widely
accessible.
A protected member is visible anywhere in the module where its class is declared and
from any descendant class, regardless of the module where the descendant class
appears. A protected method can be called, and a protected field or property read or
written to, from the definition of any method belonging to a class that descends from
the one where the protected member is declared. Members that are intended for use
only in the implementation of derived classes are usually protected.
A public member is visible wherever its class can be referenced.
Published members
Published members have the same visibility as public members. The difference is that
runtime type information (RTTI) is generated for published members. RTTI allows an
application to query the fields and properties of an object dynamically and to locate
its methods. RTTI is used to access the values of properties when saving and loading
form files, to display properties in the Object Inspector, and to associate specific
methods (called event handlers) with specific properties (called events).
Published properties are restricted to certain data types. Ordinal, string, class,
interface, variant, and method-pointer types can be published. So can set types,
provided the upper and lower bounds of the base type have ordinal values between 0
and 31. (In other words, the set must fit in a byte, word, or double word.) Any real
type except Real48 can be published. Properties of an array type (as distinct from
array properties, discussed below) cannot be published.
Some properties, although publishable, are not fully supported by the streaming
system. These include properties of record types, array properties of all publishable
types (see “Array properties” on page 7-20), and properties of enumerated types that
include anonymous values (see “Enumerated types with explicitly assigned
ordinality” on page 5-8). If you publish a property of this kind, the Object Inspector
won’t display it correctly, nor will the property’s value be preserved when objects are
streamed to disk.
All methods are publishable, but a class cannot publish two or more overloaded
methods with the same name. Fields can be published only if they are of a class or
interface type.