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



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə165/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   161   162   163   164   165   166   167   168   ...   294
DelphiLanguageGuide

Overriding Versus Hiding
If a method declaration specifies the same method identifier and parameter signature as an inherited method, but
doesn't include override, the new declaration merely hides the inherited one without overriding it. Both methods exist
in the descendant class, where the method name is statically bound. For example,
type 
   T1 = class(TObject) 
      procedure Act; virtual; 
   end; 
   T2 = class(T1) 
      procedure Act;   // Act is redeclared, but not overridden 
   end; 
143


var
   SomeObject: T1; 
begin 
   SomeObject := T2.Create; 
   SomeObject.Act;    // calls T1.Act 
end;
Reintroduce
The reintroduce directive suppresses compiler warnings about hiding previously declared virtual methods. For
example,
procedure DoSomething; reintroduce;   // the ancestor class also has a DoSomething method
Use reintroduce when you want to hide an inherited virtual method with a new one.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   161   162   163   164   165   166   167   168   ...   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