在delphi中, reintroduce作用

当在子类中重载或者重新声明父类的虚方法时,使用     reintroduce   关键字告知编译器,可以消除警告信息.如:  
   
     TParent   =   class  
         procedure   proc;virtual;  
     end;  
   
     TChild   =   class(TParent)  
         procedure   proc;   reintroduce;   overload;     //重载  
         //procedure   proc;   reintroduce;     //重新声明  
     end;  
 如果此时没有reintroduce关键字,则会出现如下的警告信息:  
   
 [Warning]   Unit1.pas(20):   Method   'proc'   hides   virtual   method   of   base   type  'TParent'  
   
典型的应用是,你要改变CREATE的参数,那么重新声明的CREATE跟父类的不一样,所以要REINTRODUCE,实际的函数可能是这个样子:  
   
 Constructor   Create(AOwner:   TComponent;   NewParam:   Integer);  
 begin  
     Create(AOwner);  
     ...   //do   something   for   NewParam

相关文章:

  • 2022-01-19
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2021-06-09
  • 2021-12-13
猜你喜欢
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
相关资源
相似解决方案