| NO.0 | 标题:朱元琪:关于Delphi下子类调用父类虚函数的一个问题 | 作者:施维刚 | 时间:2002-9-28 15:03:12 | |||||||||
| 两个Delphi class,声明如下: TFather = class public procedure ShowMe; virtual; end; TSon = class(TFather) public procedure ShowMe; override; end; ———————————————————————— 下面是实现 { TFather } procedure TFather.ShowMe; begin Showmessage('Hi , this is father!'); end; { TSon } procedure TSon.ShowMe; begin Showmessage('Hi, this is son'); end; ---------------------------------—————— 现在有这样一段程序: procedure foo; var ASon: TSon; begin ASon := TSon.Create; try {这里如何通过ASon来调用TFather中的ShowMe?} finally ASon.Free; end; end; 我想知道如何在上面程序段中注释部分调用父类TFather的ShowMe方法,C++中只要把变量强制类型转换成父类即可实现,可是我在Delphi中用TFather(ASon).ShowMe,显示的还是"Hi, this is son"。有没有高人告诉我如何通过ASon显示"Hi, this is father"? | ||||||||||||
| ||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| ||||||||
博客涉及Delphi和C++相关内容,包含重构操作,还提及了class、integer、string等类型。这些信息技术相关元素是博客的关键信息。
3304

被折叠的 条评论
为什么被折叠?



