题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-09-29 19:18:41

[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。
#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;

更多"参照函数模板的写法,完成非模板函数的定义,语句为______。 #i"的相关试题:

[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。
#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[]="efg";
eout<<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; }
[简答题]完成下面类中成员函数的定义。
#include<iostream>
#include<string>
using namespace std;
class str
private:
char*st;
public:
str(char*a)
set(a);
str&operator=(______)
delete st;
set(a.st);
return*this;

void show( )cout<<st<<endl;
~str( )delete st;
void set(char*s)//初始化st
______
strcpy(st,s);


void main( )
str s1("he"),s2("she");
s1.show( ),s2.show( );
s2=s1;
s1.show( ),s2.show( );

[填空题]下列程序是一个函数模板,用于把数组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]; }
[简答题]完成下面类中成员函数的定义。
#include<iostream.h>
#include<iomanip.h>
class Arr
protected:
float*p;
int n;//数组大小(元素个数)
public:
Arr(int sz=10)
n=sz;
p=new float[n];

~Arr(void)
______
int Getn(void)const

return n;

float*operator[](int i)
______
void Print( );

void Arr::Print( )
int i;
for(i=0;i<this->Getn( );i++)
if(i%10= =0)
cout<<endl;
cout<<setw(6)<<p[i];

cout<<endl:

void main( )
Arr a(20);
for(int i=0;i<a.Getn( );i++)
a[i]=i*2;
a.Print( );

[简答题]完成下面类中成员函数的定义。
#include<iostream.h>
class vehicle
protected:
int size;
int speed;
public:
void set(int s)speed=s;
______get( )return speed/10;

class car:public vehicle
public:
int get( )return speed;

class truck:public vehicle
public:
int get( )return speed/2;

int max(______)
if(v1.get( )>v2.get( ))
return 1;
else
return 2;

void main( )
truck t;
car c;
t.set(160);
c.set(80);
cout<<max(t,c)<<endl;//此结果输出为2

[简答题]写出模板函数实现数值型数组元素值按从小到大排序的程序。
#include<iostream>
using namespace std;
______
void sort(T b[],int n)
T temp;
int i,j;
T*a=new T[n];
for(i=0;i<n;i++)
a[i]=b[i];
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(a[i]>a[j])
temp=a[i];
a[i]=a[j];
a[j]=temp;



for(i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<endl;
delete a;

void main( )
int i,n=6;
int a[]=5,1,9,10,3,8;
sort______;
for(i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<endl;

[单项选择]在定义函数模板或类模板时,开头的保留字是
A. typename
B. template
C. class
D. typedef
[填空题]下面的函数定义是某函数模板能够生成的函数实例
intsquare(int n)(return n*n;)
double square(double n)(retum n*n;)
由此可知,该函数模板的定义是______。
[单项选择]下列函数的功能是( )。
#include<iostream>
using namespace std;
void main( )

char a;int i;
cin>>a;
for(i=1;i<=10;i++)

if((a>= ’a’)&&(a<= ’z’))
a=a-i;
cout<<a;


A. 把a中的小写字母变成大写字母
B. 把a中的大写字母变成小写字母
C. 把a中的所有字母变成小写字母
D. 把a中的字符变成它前面i个的字符
[简答题]#include<iostream>
#include<fstream>
#include<string>
using namespace std;
class A
public:
A(const char*na)strcpy(name,na);
private:
char name[80];

class B:public A
public:
B(const char*nm):A(nm)
void show( );

void B::show( )
cout<<"name:"<<name<<endl;

void main( )
B b1("B");
b1.show( );

[单项选择]下面函数的运行结果是( )。
#include <iostream>
using namespace std;
class A
public:
A( )
int Min(int a,int b)return a<b a:b;
int Min(int a,int b,int c)
if(a<b)return a<c a:c;
else return b<c b:c;

~A( )

void main( )
A a;
cout<<a.Min(1,2,3)<<a.Min(2,0);

A. 10
B. 12
C. 30
D. 32

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码