下面的函数定义是某函数模板能够生成的函数实例 int square(int n){return n*n;) double square(double n){return n*n;} 由此可知,该函数模板的定义是( )。

admin2023-03-19  22

问题 下面的函数定义是某函数模板能够生成的函数实例
    int square(int n){return n*n;)
    double square(double n){return n*n;}
    由此可知,该函数模板的定义是(    )。

选项 A、template(type n)
B、type square(type n)
C、{return n*n;}
D、template(type n)type square(type n){return n*n;)

答案D

解析 这是一个平方运算的函数模板,由上述实例可知道模板有一个形参n,函数名为square,所以可得模板template(type n)typesquare(type n){return n*n;}。
转载请注明原文地址:https://kaotiyun.com/show/HR0D777K
0

相关试题推荐
最新回复(0)