</pre><pre name="code" class="cpp">#include<iostream>
#include<string>
using namespace std;
template <typename T>
const T& max(const T& x, const T& y)
{
if( y < x )
return x;
return y;
}
int main()
{
cout << max(3,7) << endl;
cout << max(3.0,4.0) << endl;
cout << max<double>(3,8.0) << endl;
cout << max<char>('A','C');
return 0;
}
原文:http://blog.csdn.net/u013163178/article/details/42582459