函数模板特化

#include <iostream>
template <typename T>
T max(T x, T y)
{
    return x > y ? x : y;
}

//函数模板特化
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;
}
原文地址:https://www.cnblogs.com/zzyoucan/p/6129654.html