标签:定义 直接 函数 font 无法 不同类 ++ 功能 template
1 template <typename AnyType> 2 void Swap(AnyType & a, AnyType & b) 3 { 4 AnyType temp; 5 temp=a; 6 a=b; 7 b=temp; 8 }
1 template<typename T> 2 void Swap(T &, T &); 3 4 template<> void Swap<job>(job &, job &); // 或 template<> void Swap(job &, job &);
1 int i; 2 double j; 3 Add<double>(i,j); // 参数 i 传递的值被转换成了 double 类型
标签:定义 直接 函数 font 无法 不同类 ++ 功能 template
原文地址:https://www.cnblogs.com/suui90/p/12754564.html