问题
填空题
执行下面程序输出的是 【15】 。 #include <iostream> using namespace std; template <typename T> T total(T *data){Ts=0;while( *data) s+=*data++;return s; } int main(){int s[]={1,3,5,7,0,2,4,6,8};cout<<total(s);return 0; }
答案
参考答案:P
解析: 本题中函数模板实现的功能是计算所传入数组data中元素值为0的元素前面所有元素值的和。