A-A+

下列函数模板定义中错误的是A.template<class Q>B.template<cla

2022-08-05 21:32:40 问答库 阅读 172 次

问题详情

下列函数模板定义中错误的是
A.template<class Q>
B.template<class Q> Q F(Q x){return Q+x;} Q F(Q x){return x+x;}
C.template<class T>
D.template<class T> T F(T x){return x * x;} bool F(T x){return x>1;}请帮忙给出正确答案和分析,谢谢!

参考答案

正确答案:A
解析:在函数模板定义中,类型参数不能参与运算。

考点:函数,定义