【发布时间】:2014-04-07 22:21:18
【问题描述】:
我试图弄清楚这与它的功能有什么区别。
第一个是添加到表达式的模板函数:
template <class T,class Y,class Z>
Z add(T t,Y y)
{
return t+y;
}
专业化_1:
template<>
int add<int,int,int>(int t,int y)
{
return t+y+10000;
}
专业化_2:
int add(int t,int y)
{
return t+y+10000;
}
speciaization_1 和 specialization_2 有什么区别? 声明前需要使用template吗???
【问题讨论】:
-
模板可与 anyType 一起使用,而您的函数仅适用于
int -
我知道为什么我们必须使用模板,但我询问了 spec_1 和 spec_2 之间的区别