C++ | 函数模板
1 #include<iostream> 2 using namespace std; 3 template<class T> 4 T maxx(T x, T y) { 5 return x > y ? x : y; 6 } 7 8 9 int main() { 10 int a = 1, b = 2; 11 double c = 3.0, d = 4.0; 12 cout << max(a,b)<< endl; 13 cout << maxx<double>(c,d) << endl; 14 }