RAD Studio Athens

E2273

Go Up to Error and Warning Messages (Delphi)

An attempt has been made to call an overloaded procedure but no suitable match could be found.


program overload;
  procedure f(xย : Char); overload;
  begin
  end;

  procedure f(xย : Integer); overload;
  begin
  end;

begin
  f(1.0);

end.


In the use of f presented here, the compiler is unable to find a suitable match (using the type compatibility & overloading rules) given the actual parameter 1.0.



program overload;
  procedure f(xย : char); overload;
  begin
  end;

  procedure f(xย : integer); overload;
  begin
  end;

begin
  f(1);
end.


Here, the call to f has been changed to pass an integer as the actual parameter which will allow the compiler to find a suitable match. Another approach to solving this problem would be to introduce a new procedure which takes a floating point parameter.