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.

Forward declarations allow mutually dependent classes. For example, type

TFigure = class; // forward declaration TDrawing = class

Figure: TFigure;


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.


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

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment