Delphi中inherited问题

来源:互联网 发布:手机即时策略游戏 知乎 编辑:程序博客网 时间:2024/06/06 08:58
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;
原创粉丝点击