call of overloaded ‘max(char&, char&)’ is ambiguous
问题 #include <iostream> using namespace std; int max (int a, int b) { return a<b?b:a; } template <typename T> T max (T a, T b) { return a<b?b:a; } template <typename T> T max (T a, T b, T c) { return max (max(a,b), c); } int main() { // The call with two chars work, flawlessly. :: max ('c', 'b'); // This call with three chars produce the error listed below: :: max ('c', 'b', 'a'); return 0; } Error: error: call of overloaded ‘max(char&, char&)’ is ambiguous Shouldn't this max ('c', 'b', 'a') call