Solved

Ambiguous overloaded call to ...

Posted on 2004-04-15
3
1,150 Views
Last Modified: 2011-10-03
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;
0
Comment
Question by:rbohac
  • 2
3 Comments
 
LVL 7

Expert Comment

by:sftweng
ID: 10836939
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.
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 125 total points
ID: 10837495

Its abiguous because you defined the second call with a default value, meaning the integer param is not required to be passed, so it can't tell the difference between the first and the second definition.

If you code it as:

function DBGetValue(Module,Key:String; const Default: Integer): Integer; overload;

Then it quits complaining.

Regards,
Russell
0
 
LVL 7

Expert Comment

by:sftweng
ID: 10837514
Doh! Of course.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now