面试题答案
一键面试#include <iostream>
#include <string>
// 函数模板,返回两个参数中的较大值
template<typename T>
T max(T a, T b) {
return a > b? a : b;
}
// 函数模板特化,处理std::string类型参数
template<>
std::string max<std::string>(std::string a, std::string b) {
return a.length() > b.length()? a : b;
}