Forward Declarations in Delphi - ablealias/Delphi GitHub Wiki
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. Forward declarations allow mutually dependent classes. For example,
type
TFigure = class; // forward declaration
TDrawing = class
Figure: TFigure;
…
end;
TFigure = class // defining declaration
Drawing: TDrawing;
…
end;
Do not confuse forward declarations with complete declarations of types that derive from TObject without declaring any class members.
type
TFirstClass = class; // this is a forward declaration
TSecondClass = class // this is a complete class declaration
end; //
TThirdClass = class(TObject); // this is a complete class declaration