问题 填空题

下面的函数定义是某函数模板能够生成的函数实例

intsquare(int n)(return n*n;)

double square(double n)(retum n*n;)

由此可知,该函数模板的定义是______。

答案

参考答案:template(typen)type square(type n){retum n*n;)。

解析:

这是一个平方运算的函数模板,由上述实例可知遭模板有一个形参n,函数名为square;所以可得模板template(typc n)type csquare(type n){return n*n;)。

判断题
填空题