选择题
32.
下面不属于同一函数模板的是
。
A、
template<class t1>
t1 max(t1 &a,t1 &b)
{…}
template<class t2>
t2 max(t2 &a,t2 &b)
{…}
B、
template<class t1>
t1 max(t1 a,t1 b)
{…}
template<class t2>
t2 max(t2 &a,t2 &b)
{…}
C、
template<class t1>
t1 max(t1 * a,t1 * b)
{…}
template<class t2>
t2 max(t2 &a,t2 &b)
{…}
D、
template<class t1>
t1 max(t1 a,t1 b)
{…}
template<class t2>
t2 max(t2 &a,t2 &b,t2 c)
{…}
【正确答案】
D
【答案解析】
函数模板的重载是靠模板参数的数量不同来区分的,因为函数模板是抽象的,有待于进一步实例化,所以靠参数类型无法区别调用哪个函数模板。
提交答案
关闭