Link to home
Start Free TrialLog in
Avatar of rbohac
rbohac

asked on

Ambiguous overloaded call to ...

I'm trying to write an overloaded function that can return data as different types. Basically the function I will altimately be calling will return a string, hoever I want to write a wrapper around this so that I can get results in other types (Integer, real, etc..)

Heres my example.. When I try to compile this, I get "Ambiguous overloaded call to 'DBGetValue'.. What am I doing wrong here?

function DBGetValue(Module,Key:String):String; overload;
begin
  Result := '12345';
end;

function DBGetValue(Module,Key:String; const Default:Integer = 0): Integer; overload;
var s:String;
begin
  try
    s      := DBGetValue(Module,Key);
    Result := StrToInt(s);
      except
      Result := Default;
    end;
end;
Avatar of sftweng
sftweng

I suspect that it's getting confused by the recursive nature of the call (DBGetValue within DBGetValue). Perhaps you should name the wrappers DBGetValue and the underlying function DBGetValueBase.
ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Doh! Of course.