Can someone help me understand why these 2 function calls are ambiguous:
int greater(int i, int j) { return ( i > j ? i : j); }
double greater(double x, double y) { return ( x > y ? x : y); }
int main(){
int i = 10, j = 5;
double x = 7.7, y = 14.5;
cout << greater(i, j);
cout << greater(x, y);
}
The exact error from g++ is:
reference to ‘greater’ is ambiguous cout << greater(i, j);
This is from Prof. Pohl's excellent book on C++ for C Programmers. I'm compiling with g++ (GCC) 4.9.2. thank you, Mainecat