I have two overloaded function like below:
void print(int i) { ... }
void print(float f) { ... }
Its giving me this error for print(1.2);:
error: call of overloaded 'print(double)' is ambiguous
Can anyone explain me why?
1.2 is a double literal not a float.
So the compiler requires an explicit disambiguation.
1.2f would work as that is a float literal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With