1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream> template <typename T> T max(T x, T y) { return x > y ? x : y; } int main() { cout<<::max<int>(4,4.8)<<"\n"; cout<<::max<double>(3,4.7)<<"\n"; }
1 2 3
cc1plus: warnings being treated as errors In function 'int main()': Line 11: warning: passing 'double' for argument 2 to 'T max(T, T) [with T = int]'