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:Stri ng):String ; overload;
begin
Result := '12345';
end;
function DBGetValue(Module,Key:Stri ng; const Default:Integer = 0): Integer; overload;
var s:String;
begin
try
s := DBGetValue(Module,Key);
Result := StrToInt(s);
except
Result := Default;
end;
end;
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:Stri
begin
Result := '12345';
end;
function DBGetValue(Module,Key:Stri
var s:String;
begin
try
s := DBGetValue(Module,Key);
Result := StrToInt(s);
except
Result := Default;
end;
end;
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Doh! Of course.