作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这有效:
constructor TMyObj.Create;
begin
inherited;
end;
为什么这也不起作用?
function TMyObjEx.Import(CONST FileName: string; CONST x, y, z: Integer): string;
begin
result:= inherited; // Import(FileName, x, y, z); <--- Compiler says: "incompatible types"
//do other stuff here
end;
TMyObjEx 的声明如下:
TYPE
TMyObj = class(TChObj)
private
protected
public
function Import (CONST FileName: string; CONST x, y, z: Integer): string; virtual;
end;
TMyObjEx= class(TMyObj)
private
protected
public
function Import(CONST FileName: string; CONST x, y, z: Integer): string; override;
end;
最佳答案
这是正确答案。
执行此操作的正确方法如您上面所述:
function TMyObjEx.Import(CONST FileName: string; CONST x, y, z: Integer): string;
begin
result:= inherited Import(FileName, x, y, z);
//do other stuff here
end;
该语言不支持您想要的方式。
最终回答了“为什么这不起作用?”的问题。是因为这不是语言的设计方式。
关于delphi - 如何在重写的虚函数中调用 `Inherited` 祖先方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/340842/
我有一个特别的问题想要解决,我不确定是否可行,因为我找不到任何信息或正在完成的示例。基本上,我有: class ParentObject {}; class DerivedObject : publi
在我们的项目中,我们配置了虚 URL,以便用户可以在地址栏中输入虚 URL,这会将他们重定向到原始 URL。 例如: 如果用户输入'http://www.abc.com/partner ',它会将它们
我是一名优秀的程序员,十分优秀!