Solved

Ambiguous overloaded call to ...

Posted on 2004-04-15
3
1,166 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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