Quick start manual
7-6
Delphi Language Guide
Class types
A class cannot have published members unless it is compiled in the {$M+} state or
descends from a class compiled in the {$M+} state. Most classes with published
members derive from TPersistent, which is compiled in the {$M+} state, so it is
seldom necessary to use the $M directive.
Automated members
Automated members have the same visibility as public members. The difference is
that Automation type information (required for Automation servers) is generated for
automated members. Automated members typically appear only in Windows classes
and are not recommended for Linux programming. The automated reserved word is
maintained for backward compatibility. The TAutoObject class in the ComObj unit
does not use automated.
The following restrictions apply to methods and properties declared as automated.
• The types of all properties, array property parameters, method parameters, and
function results must be automatable. The automatable types are Byte, Currency,
Real, Double, Longint, Integer, Single, Smallint, AnsiString, WideString, TDateTime,
Variant, OleVariant, WordBool, and all interface types.
• Method declarations must use the default register calling convention. They can be
virtual, but not dynamic.
• Property declarations can include access specifiers (read and write) but other
specifiers (index, stored, default, and nodefault) are not allowed. Access
specifiers must list a method identifier that uses the default register calling
convention; field identifiers are not allowed.
• Property declarations must specify a type. Property overrides are not allowed.
The declaration of an automated method or property can include a dispid directive.
Specifying an already used ID in a dispid directive causes an error.
On Windows, this directive must be followed by an integer constant that specifies an
Automation dispatch ID for the member. Otherwise, the compiler automatically
assigns the member a dispatch ID that is one larger than the largest dispatch ID used
by any method or property in the class and its ancestors. For more information about
Automation (on Windows only), see “Automation objects (Windows only)” on
page 10-11.
Forward declarations and mutually dependent classes
If the declaration of a class type ends with the word class and a semicolon—that is, if
it has the form
type className = class;
with no ancestor or class members listed after the word class—then it is a forward
declaration. A forward declaration must be resolved by a defining declaration of the
same class within the same type declaration section. In other words, between a
forward declaration and its defining declaration, nothing can occur except other type
declarations.