函数模板特化
#include <iostream>
template <typename T>
T max(T x, T y)
{return x > y ? x : y;
}//函數(shù)模板特化
template <>
const char* max(const char* x, const char* y){return strcmp(x, y) > 0 ? x : y;
}int main(){std::cout << max(1, 2);std::cout << max("hello", "world");return 0;
}
?
總結(jié)