The following code defines three overloaded methods called Test that have var arguments of different types. The code does not compile, with errors as indicated. Why? The methods’ arguments are sufficiently different to distinguish between them.
interface
type
VarTest = public static class
public
method Test(var a, b: Integer); // <-- (I) Previous declaration was here
method Test(var a, b: Double); // <-- (X) Duplicate method
method Test(var a, b: String); // <-- (X) Duplicate method
end;
implementation
method VarTest.Test(var a, b: Integer);
begin
a := 0; b := 0;
end;
method VarTest.Test(var a, b: Double); // <-- (X) Declaration missing
begin
a := 0; b := 0;
end;
method VarTest.Test(var a, b: String); // <-- (X) Declaration missing
begin
a := 'a'; b := 'b';
end;
Remove all the vars and the code compiles, but that is not what I need.