hiya, i'm having this weird error on my project. As far as I know "ambiguous call to overloaded function" should only occur when the compiler must choose from several methods, but here i don't think it's the case. I've got the following class: - class item
-
{
-
public:
-
item(string id_,string datatype_);
-
//item(string id_,string datatype_,int periodo_);
-
//item(string id_,string datatype_,string headerfile_);
-
//item(string id_, string datatype_, int periodo_=1, string headerfile_="");
-
//item(const item& it);
-
-
void set_id(string id_);
-
void set_datatype(string datatype_);
-
void set_periodo(int periodo_);
-
void set_headerfile(string headerfile_);
-
-
string get_id();
-
string get_datatype();
-
int get_periodo();
-
string get_headerfile();
-
-
item& operator=(const item& var);
-
// item operator*();
-
virtual ~item();
-
-
public:
-
string id;
-
string datatype;
-
int periodo;
-
string headerfile;
-
};
-
-
-
(most of the methods are commente because I was going crazy trying to solve this)
-
-
the main is like this (just for testing):
-
-
int main()
-
{
-
item var3("string1", "string2");
-
-
return 0;
-
}
-
all the other commented methods work, but this constructor raises the error,
any help is much appreciated
thanks in advance.
6 3797 -
item(string id_,string datatype_);
-
item(string id_, string datatype_, int periodo_=1, string headerfile_="");
Those are the two functions that are ambiguous. Which function to use when
someone does this?
kind regards,
Jos
Those are the two functions that are ambiguous. Which function to use when
someone does this?
kind regards,
Jos
that should summon the 1st function: - item(string id_,string datatype_);
that should summon the 1st function: - item(string id_,string datatype_);
Nope, the other two parameters are optional (you supplied default values for them).
kind regards,
Jos
Nope, the other two parameters are optional (you supplied default values for them).
kind regards,
Jos
hm... but even either function, the problem persists...
item var("abc", "def");
should summon both
item(string id_,string datatype_);
and
item(string id_, string datatype_, int periodo_=1, string headerfile_="");
thus creating ambiguity. so if either function was removed, visual studio should call the correct function, right? but the poroblem persists.. =(
Maybe you could have a single constructor giving default values to all parameters? On the one hand, you wouldn't be able to use the constructor with 3 strings, but on the other, there would be no ambiguity.
hm... but even either function, the problem persists...
item var("abc", "def");
should summon both
item(string id_,string datatype_);
and
item(string id_, string datatype_, int periodo_=1, string headerfile_="");
thus creating ambiguity. so if either function was removed, visual studio should call the correct function, right? but the poroblem persists.. =(
What Jos stated should be correct. So post the error messages and the lines that they refer to with some context around them. That way we can determine what the problem is.
Adrian
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ¤ Alias |
last post by:
I have a function named
getID3info (lvwDiscInfo.SelectedItem).
What is the difference between
getID3info (lvwDiscInfo.SelectedItem)
and
Call getID3info(lvwDiscInfo.SelectedItem) ?
|
by: Steffen |
last post by:
Hi,
I stumbled across the following error
foo.cc: In function `int main()':
foo.cc:15: error: no matching function for call to `Bar::foo(int)'
foo.cc:9: error: candidates are: void...
|
by: Denis Samoilov |
last post by:
We have a namespace N which includes enumeration ENUM1 and a class C with
property C.Enum1, e.g.
namespace N
{
public enum ENUM1{};
public class C {
public ENUM1 Enum1
{
get{}
set{}
|
by: Gary Brown |
last post by:
Hi,
Why are
fn(object parameters)
and
fn(params object parameters)
|
by: John Goche |
last post by:
Hello,
Could anyone please provide with some information on the
C++ overloaded cast operator and in which circumstances
this might be useful? I have consulted several references
but found no...
|
by: Frederick Gotham |
last post by:
If we have a simple class such as follows:
#include <string>
struct MyStruct {
std::string member;
MyStruct(unsigned const i)
{
|
by: kartik369 |
last post by:
hi while compiling my code im getting these errors:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(4729): error C2872: 'FILETIME' : ambiguous symbol
...
|
by: Michael Scott |
last post by:
This is driving me nuts. Can anyone help?
I have a program which searches for and analyses Access databases
across a corporate network. At one point in the code I am looping
quickly through all...
|
by: John Kotuby |
last post by:
Hi all.
I am using VS 2005 and VB.NET.
Lately as my Web Application is getting larger, I have been getting strange
compiler messages like the following:
---------------------------
Compiler...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |