Overloading ambiguity: char and unsigned char : overloading ambiguity « Function « C++ Tutorial






#include <iostream> 
using namespace std; 
 
char f(unsigned char ch); 
char f(char ch); 
 
int main() 
{ 
  cout << f('c');  // this calls f(char) 
  //cout << f(88) << " "; // Error, ambiguous! 
 
  return 0; 
} 
 
char f(unsigned char ch) 
{ 
  return ch-1; 
} 
 
char f(char ch) 
{ 
  return ch+1; 
}
d








7.14.overloading ambiguity
7.14.1.Overloading ambiguity: float and double
7.14.2.Overloading ambiguity: char and unsigned char
7.14.3.Overloading abiguity: default parameter
7.14.4.Overloading a function - removing ambiguity with a cast