RAD Studio Athens

E2518

Go Up to Error and Warning Messages (Delphi)

Overloading the addition operator requires that one of the parameters is the same type as the return type.


program E2518;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  TFirstRec = record
  end;
  TSecondRec = record
  end;
  TThirdRec = record
    class operator Add(_a: TFirstRec; _b: TSecondRec): TThirdRec;
end;

class operator TThirdRec.Add(_a: TFirstRec; _b: TSecondRec): TThirdRec;
begin
   // code to initialize Result from the values of _a and _b
end;

begin
  Writeln('	E2518 Operator ''%s'' must take least one ''%s'' type in parameters');
end.