I am using the operator overloading for records in Delphi 2006. (Please don't answer this question by telling me not to.)
I have two record types with the implicit operator overloaded. They are both only in the implementation of the module, not exposed through the interface.
My problem is, now that they are mutually dependent, I don't know how to forward declare the second type to the compiler. I know how to do this with functions, procedures, and classes, but not with records.
Here is a simplified example of what I am trying to do:
implementation
type
TMyRec1 = record
Field1 : Integer;
class operator Implicit(a: TMyRec2): TMyRec1; // <---- Undeclared Identifier here.
end;
TMyRec2 = record
Field2: Integer;
class operator Implicit(a: TMyRec1): TMyRec2;
end;
class operator TMyRec1.Implicit(a:TMyRec2): TMyRec1;
begin
Result.Field1 := a.Field2;
end;
class operator TMyRec2.Implicit(a:TMyRec2): TMyRec2;
begin
Result.Field2 := a.Field1;
end;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…