?
Solved

Ambiguous overloaded call to ...

Posted on 2004-04-15
3
Medium Priority
?
1,181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

764 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