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

admin2021-06-10  27

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

选项 A、templateTfun(Tx){returnx;}
B、templateTfun(Tx,intn){returnx*n;}
C、templateTfun(T*p){return*p;}
D、templateTclassA{Tn;};

答案D

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

最新回复(0)