gpt4 book ai didi

delphi - 在类运算符的上下文中继承是什么意思

转载 作者:行者123 更新时间:2023-12-03 18:27:20 25 4
gpt4 key购买 nike

如果我在 interface 中输入我的记录定义然后按 ctrl + alt + C Delphi 填写以下 stub 。

  class operator P<T>.GreaterThan(a, b: P<T>): Boolean;
begin
inherited; <<-- ???

end;

您不能从记录继承, inherited 是什么?在这种情况下是什么意思?

Delphi 甚至不一致:

界面:
class operator Implicit(a: pointer): P<T>; inline;
class operator Implicit(a: P<T>): pointer; inline;
class operator Implicit(Cell: TCell<T>): P<T>; inline;
class operator Implicit(P: P<T>): TCell<T>; inline;

执行:
  class operator P<T>.Implicit(a: pointer): P<T>;
begin <<--- nothing
end;

class operator P<T>.Implicit(a: P<T>): pointer;
begin
inherited; <<-- now you see it...
end;

class operator P<T>.Implicit(Cell: TCell<T>): P<T>;
begin <<-- now you don't
end;

class operator P<T>.Implicit(P: P<T>): TCell<T>;
begin
end;

我怀疑 Delphi 将一个运算符作为“前导”(没有继承)并在例程中使用 inherited 遵循该实现。如果它决定参数是兼容的。

inherited 是什么意思在这种情况下是什么意思?

奖金问题
Delphi 遵循哪些规则以及需要注意哪些陷阱?

最佳答案

在这种情况下,inherited没有任何意义,因为记录不能被继承。编译器会忽略它并且不输出任何代码。看起来代码完成变得困惑。

关于delphi - 在类运算符的上下文中继承是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19238795/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com