Which function is called for calc(3) ?Code:void utils::calc(int a) { /* different code */ } void utils::calc(char b) { /* different code */ }
Also refer to :
Function overloading in C++ - Stack Overflow
Which function is called for calc(3) ?Code:void utils::calc(int a) { /* different code */ } void utils::calc(char b) { /* different code */ }
Also refer to :
Function overloading in C++ - Stack Overflow
Implicit conversions from char to int are just part of the language. C++ inherited that from C where functions such as getchar() return an int (not a char). As such the best thing to do is avoid those kinds of overloads altogether.
Sure a char can be promoted to a 32-bit int, but if the argument was a floating-point type and not a char, information would be lost.
But the idea is, how to determine which function is used ?