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

admin2020-07-30  20

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

选项 A、templateT fun(T x){retum 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/cUyp777K
0

最新回复(0)