标签:strcmp ret code str char typename iostream class max
#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; }
标签:strcmp ret code str char typename iostream class max
原文地址:http://www.cnblogs.com/zzyoucan/p/6129654.html