父类virtual和overload,子类reintroduce; overload;

 

如果函数在父类中既是虚拟方法也是重载方法,那么:
TBase=class(TObject)
function DisappearRoutinel: String; overload; virtual;
function DisappearRoutinel(const sName: String): String; overload; virtual;

派生类需要reintroduce关键字:
TDerived = class(TBase)
function DisappearRoutinel: String; reintroduce; overload;
function DisappearRoutinel(const sName: String): String; reintroduce; overload;

如果TDerived类不使用reintroduce关键字,那么Delphi就会给出警告,即覆盖了父类的函数。

注意,构造函数也要标记overload
constructor Create(const sName: String); overload;
constructor Create(const sName: String); const cHash: Cardinal); overload;

 注意,父类即使只有一个函数也可overload virtual; 而子类不管增加多少个同名,都需要reintroduce; overload;

你可能感兴趣的:(overload)