#include <iostream>
using namespace std;
template<typename T> int fun(T&) {return 1;}
template<> int fun(float&) {return 2;}
trmplate<> int fun(double&) {return 3;}
int fun(double&) {return 4;}
int main()
{
int i;
float f;
double d;
cout<<fun<int>(i)<<fun<float>(f)<<fun<double>(d)<<fun(i)<<fun(f)<<fun(d)<<endl;
return 0;
}
输出结果:
123124