【发布时间】:2023-03-17 18:46:01
【问题描述】:
如果我尝试编译以下代码,我会在最后一行 (E := R) 收到错误消息“E2010 Incompatible types: 'Extended' and 'TMyRec'”:
type
TMyRec = record
class operator Implicit(Rec: TMyRec) : Integer;
class operator Implicit(Rec: TMyRec) : Extended;
end;
class operator TMyRec.Implicit(Rec: TMyRec) : Integer;
begin
Result := 1;
end;
class operator TMyRec.Implicit(Rec: TMyRec) : Extended;
begin
Result := 1;
end;
var
R : TMyRec;
B : Byte;
E : Extended;
begin
B := R; //this is OK
E := R; //E2010 Incompatible types: 'Extended' and 'TMyRec'
end.
我请朋友尝试在XE中编译它 - 编译成功。那么这是BDS2006中的一个错误吗?有没有办法解决这个问题?
【问题讨论】:
标签: delphi operator-overloading delphi-2006