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

admin2020-04-07  26

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

选项 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 classA{T n;};

答案D

解析 第四个选项是定义类模板的,但是class前面的T是多余的。对于第二个选项,同一个类的对象相乘还是同一个类的对象,但是可能要考虑溢出的问题。
转载请注明原文地址:https://kaotiyun.com/show/jV8p777K
0

随机试题
最新回复(0)