I am not able to explain why the second call (B
) doesn't give any errors as there are two char
elements, and there is no certain match for this call.
Why it is called the second one (2.
), but not the first (1.
) version?
I've noticed that there are some automatic conversions. The thing that i don't get is why 'a'
is promoted to int and 'c'
isn't.
// 1.
int fun(int a, int b)
{
return a + b;
}
// 2.
int fun(int a, char b)
{
return b - a;
}
// 3
int fun(float a, float b)
{
return a * b;
}
int main() {
// A. B. C.
cout << fun(1,0) << fun('a','c') << fun(2.f,2.f);
return 0;
}