delphi - 尝试在 Delphi 中结合泛型和运算符重载
问题描述
以下不起作用,我想我的意图可以从代码中读取。如果可能的话,我无法找到示例或文档。
type
TV2<T> = record
X: T;
Y: T;
class operator add(a,b: TV2<T>): TV2<T>;
end;
TV2S = TV2<Single>;
TV2I = TV2<Int64>;
implementation
class operator TV2<T>.add(a, b: TV2<T>): TV2<T>;
begin
Result.X := a.X + b.X; // I'm getting "E2015 Operator not applicable to this operand type"
Result.Y := a.Y + b.Y; // I'm getting "E2015 Operator not applicable to this operand type"
end;
解决方案
推荐阅读
- spring-boot - Spring errors and warning not coming in logs when dependency of both logback and log4j is there
- document - 使用嵌入字体和内联图像的 DOC 到 HTML 文件转换
- sql-server - 有没有办法在每个 SSIS 包之前和之后启动存储过程?
- google-chrome - Chrome 记住手动接受的 SSL 证书
- html - 如何覆盖 CSS 滑块动画——带有 NAV 的纯 CSS 滑块?
- sql - 为什么当我导入 200k 数据时只导入了 7k?
- php - PHP时事通讯表单未提交
- javascript - 如何在 NestJs 服务中组织抛出业务逻辑异常?
- java - Visual Studio Code JAVA 中的条件断点
- linux - 将 CronJob 日志从 /var/log/syslog 复制到单独的文件