c++模板编程
#include<iostream>
//#include<string>
//#include<algorithm>
template <typename T>
T max(T a, T b) {
return (a > b) ? a : b;
}
int main() {
int i = max(1, 2); // 返回 2
float f = max(3.14f, 2.72f); // 返回 3.14
std::string s = std::max(std::string("apple"), std::string("banana")); // 返回 "banana"
std::cout << i << std::endl;
std::cout << f << std::endl;
std::cout << s << std::endl;
}//main()