更多"参照函数模板的写法,完成非模板函数的定义,语句为______。
#"的相关试题:
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。
#include<iostream.h>
#include<string.h>
template<class T>
T min(T a,T b)
{
return(a<b a:b);
}
char*rain(char*a,char*b)
{
______
}
void main( )
{
double a=1.23,b=3.45;
char s1[]="abed",s2[]="efg";
cout<<min(a,b)<<min(s1,s2)<<endl;
}
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为 【12】 。
#include<iostream, h>
#include<string. h>
template<class T>
T min(T a, T b)
{
return(a<b a:b);
}
char * min(char * a, char * b)
{
__________________________
}
void main( )
{
double a=1.23,b=3.45;
char s1[]="abcd",s2[]="erg";
cout<<min(a, b)<<min(s1,s2)<<end1:
}
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为 【12】 。
#include<iostream, h>
#include<string. h>
template<class T>
T min(T a, T b)
return(a<b a:b);
char * min(char * a, char * b)
__________________________
void main( )
double a=1.23,b=3.45;
char s1[]="abcd",s2[]="erg";
cout<<min(a, b)<<min(s1,s2)<<end1:
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。
#include<iostream.h)
#include(string.h>
template(class T)
T min(T a,T b)
return(a<ba:b);
char*min(char*a,char*b)
void main( )
double a=1.23,b=3.45;
chars1[]=”abcd”,s2[]=”efg”;
cout<<min(a,b)<<rain(s1,s2)<(endl;
[填空题]下列程序是一个函数模板,用于把数组a的每个元素按照逆序放入数组b中。请填空完成该函数模板的定义
template<class Type>
void Func(Type a[], Type b[], 【10】 )
{
for(int i=0;i<n;i++)
b[n-i-1]=a[i];
}
[填空题]下列程序是一个函数模板,用于把数组a的每个元素按照逆序放入数组b中。请填空完成该函数模板的定义
template<class Type>
void Func(Type a[], Type b[], 【10】 )
for(int i=0;i<n;i++)
b[n-i-1]=a[i];
[填空题]main函数中发生编译错误的语句是 【12】 。
# include <iostream. h>
class A
{
public:
int a;
const int b:
A( ) :a(10) ,b(20) {
void fun( ) const
{
cout<<"a="<<a<<"/tb="<<b<<end1;
}
};
void main( )
A obj1;
const A * ptr = new A:
ptr = &obj1;
ptr->a=lO0;
ptr->fun( ),
}
[填空题]下列类的构造函数不能通过编译,正确的构造函数应该是______。
#include<iostream.h>
class Sample
public:
int n;
const int con;
Sample(int m) con=m+1;n=m;
void disp( ) cout<<"normal:n="<<n<<endl;
void disp( )const cout<<"static:n="<<n<<endl;
;
void main( )
const Sample a (12);
Sample b (13);
a.disp( );
b.isp( );
cout<<a.n<<","<<b.con<<endl;
[填空题]在下面的类定义中,this指针的用途是 【11】 。
#include <iostream. h>
class Sample
{
int x,y;
public:
Sample(int i,int j){x=i;y=j;
void asstgn(Sample sa):
};
void Sample: :assign(Sample p)
{
if (this! =&p)
{
x=p.x;
y=p.y;
}
}
[填空题]所有的函数模板定义都是以关键字 [15] 开始的。
[填空题]已知一个函数模板定义为
template <typename T1.typenaine T2>
T1 FUN(T2 n)return n*5.0;
若要求以int型数据7为函数实参调用该模板函数,并返回一个double型数据,则该调用应表示为______。