下列模板声明中,有语法错误的是( )。

admin2021-02-22  24

问题 下列模板声明中,有语法错误的是(    )。

选项 A、templateT fun(T X){return x;}
B、templateT fun(T x,int n)}return x*n;}
C、templateT fun(T*p){return*p;}
D、templateT class A{T n;};

答案B

解析 本题考查模板的定义,B选项中x为T类型的,n为int型的,但是x*n就不一定是T类型的,所以错误答案为B。
转载请注明原文地址:https://kaotiyun.com/show/I1fp777K
0

最新回复(0)