Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework


Forward Declarations and Mutually Dependent Classes



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə157/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   153   154   155   156   157   158   159   160   ...   294
DelphiLanguageGuide

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; 
           ... 
      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
137



Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   153   154   155   156   157   158   159   160   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin