文件操作和模板
2 试题
1.
下列函数模板中定义正确的是:
template < class T1, class T2 >
T1 fun (T1,T2) { return T1 + T2; }
template < class T >
T fun(T a,T b) { return a + b ; }
template < class T >
T fun(T a) { return T + a;}
tempmlate < class T1,class T2 >
T1 fun(T1,T2) { return T1 + T2 ; }
2.
下列类模板中定义正确的是:
template < class T1,class T2 >
class A : {
T1 b;
int fun( int a ) { return T1+T2; }
};
template < class T1,class T2 >
class A {
public:
T2 b; T1 a;
A<T1>() { }
T1 fun() { return a; }
};
template < class T1,class T2 >
class A {
T2 b;
T1 fun( double a ) { b = (T2) a;
return (T1) a; }
};
template < class T1,class T2 >
class A {
int T2;
T1 fun( T2 a ) { return a + T2; }
};