Delphi中inherited问题

时间:2020-12-03 11:38:50   收藏:0   阅读:15
inherited Create(AOwner); 和直接写inherited有区别吗 

有区别,inherited Create是指定调用父类的Create方法,当然你也可以inherited Destory等等,
如果直接写inherited则默认以本方法名在父类中调用
 
inherited就是调用祖先类的函数,如果不带参数就是默认调用同名函数
如果

技术图片

 

 

带参数则表明子类中的函数个数可能比祖先类要多取其中的几个参数传过去
例如
祖先类有个函数 Create(AName:string);
子类有个函数 Create(AName:string;AComponent:TObject);override;
那么子类的Create函数内就可以这样调用祖先类:
procedure TAClass.Create(AName:string;AComponent:TObject);
begin
    Inherited Create(AName);
end;
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!