已知int DBL(int n){return n+n;}和long DBL(Long n){return n+n;} 是一个函数模板的两个实例,则该函数模板的定义是______。
查看答案
下列程序的输出结果是______。#includeusing namespace std;templateT fun(T a,T b) { return(a<=b)?a:b; }int main(){ cout<
写出下列程序的执行结果是:__________________。#include using namespace std;template double average( T *array,int size ){ T sum = 0; for( int i=0; i
写出下列程序的执行结果是:__________________。#include using namespace std;template class Base{ public: Base( T i , T j ) { x = i; y = j; } T sum() { return x + y; }private: T x , y;} ;void main(){ Base obj2(3.3,5.5); cout << obj2.sum() <<","; Base obj1(3,5); cout << obj1.sum() << endl;}
写出下列程序的执行结果是:__________________。#include using namespace std;template void fun( T &x, T &y ){ T temp; temp = x; x = y; y = temp;}void main(){ int i , j; i = 10; j = 20; fun( i, j ); cout << "i=" << i << "," << "j=" << j << ","; double a , b; a = 1.1; b = 2.2; fun( a, b ); cout << "a=" << a <<","<< "b=" << b << endl;}