I'm learning about function overloading in C++ and I was having a doubt on function matching. Running below code I was getting
error C2668: 'function' : ambiguous call to overloaded function
.
The reson why I got error was clearly answered in this link.
The number 1.2 and 2.2 are type double
.Although there is one more doubt which I have and was not answered there.
When I try to call function(1.2,2) or function(1,2.2) it is printing as "int function". Why it is not giving error same as above.
CODE:
void function(int y,int w)
{
printf("int function");
}
void function(float y,float w)
{
printf("float function");
}
int main()
{
function(1.2,2.2);
return 0;
}