void foo(int,int) {}
void foo(int ,float) {}
void foo(float,int) {}
void main()
{
unsigned int i = 10;
unsigned float f = 1.0; //line 5
foo(i,f); // ambiguous call error
}
replacing line 5 by
float f = 1.0;
makes the program work. Why is it so?
I am working on visual studio 2005.
There is no such data type as
unsigned float. Pay attention to compiler warnings; if you’re not getting any bump up the warning level. From running this example on Visual Studio 2010 it looks like the compiler ignores thefloatkeyword in the declarationThis makes
fanunsigned int. Since you don’t have an overload offoo()that takes anintandunsigned intthe compiler is unable to deduce which overload to call. If you add another overloadthe ambiguous call error disappears.