In this code:
void f(float f, long int i) { cout << "1" << endl; }
void f(float f, float d) { cout << "2" << endl; }
int main() {
f(5.0f, 5);
}
there is ambiguity. Check this! . However, the second argument is a signed integer. When binding a parameter intto a parameter long int, advancement is required, but to float, conversion.
Since the first argument is an exact match for both overloads, it is not taken into account. But with respect to the second parameter, its rank at the first overload (advance) is better than the rank of the second (transformation).
Why is there ambiguity in resolution and not choice of first overload?
source
share