template < typename T >//或者class关键字
void Swap(T& a, T& b)
{
T c = a;
a = b;
b = c;
}
隐式调用:
int a =0;
int b=1;
Swap(a,b);
显示调用:
int a=0;
int b=1;
Swap<int>(a,b);
也可以多类型的
template<class A,class B,class C> A fun(B b,C c) { reutrn b+c; } int a = fun<int,float,double>(1.0+2.00000000000)