题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-05-26 20:05:24

[简答题]使用VC6打开考生文件夹下的工程test41_3。此工程包含一个test41_3.cpp,其中定义了类Rectangle,但该类的定义并不完整。请按要求完成下列操作,将程序补充完整。 (1)定义类Rectangle的私有数据成员left,top和fight,bottom,它们都是int型的数据。请在注释“//**1**”之后添加适当的语句。 (2)添加类Rectangle的带四个int型参数1、t、r、b的构造函数的声明,并使这四个参数的默认值均为0,请在注释“//**2**”之后添加适当的语句。 (3)添加类Rectangle的成员函数SetTop( )参数为int型的t,作用为把t的值赋给类的数据成员top,添加类Rectangle的成员函数SetBottom( )参数为int型的t,作用为把t的值赋给类的数据成员bottom,请在注释“//**3**”之后添加适当的语句。 (4)完成派生类Rectangle的成员函数Show( )的定义,使其以格式“right-bottom point is(right,bottom)”输出,请在注释“//**4**”之后添加适当的语句。 源程序文件test41_3.cpp清单如下: #include <iostream.h> class Rectangle { // ** 1 ** int right, bottom; public: // ** 2 ** ~ Rectangle( ){}; void Assign(int 1, int t, int r, int b); void SetLeft(int t){left = t;} void SetRight(int t){right = t;} // ** 3 ** void SetBottom(int t){bottom = t;} void Show( ); }; Rectangle::Rectangle(int 1, int t, int r, int b) { left = 1; top = t; right = r; bottom = b; } void

更多"使用VC6打开考生文件夹下的工程test41_3。此工程包含一个tes"的相关试题:

[简答题]使用VC6打开考生文件夹下的工程RevProj7。此工程包含一个源程序文件RevMain6.cpp,但该程序运行有问题。请改正主函数中的错误,使程序的输出结果是:
MyNumber=0
MyNumber=1
MyNumber=2
源程序文件RevMain6.cpp清单如下:
//RevMain6.cpp
#include<iostream>
using namespace std;
class MyClass

public:
MyClass(int i)

MyNumber=i;

void SetMember(int m)

MyNumber=m;

int GetMember( )const

return MyNumber;

void Print( ) const

cout<<"MyNumber="<<MyNumber<<end1;

private:
int MyNumber;
;
int main( )

/* * * * * * * * *found* * * * * * * * *
MyClass *pObj=new MyClass(O);
pObj.Print( );
/* * * * * * * * *found* * * * * * * * *
pObj->MyNumber = 1;
pObj->Print( );
/* * * * * * * * *found* * * * * * * * *
MyClass. SetMember(2);
(*pObj).Print( );
return O;

[简答题]使用VC6打开考生文件夹下的工程MyProj6。此工程包含一个源程序文件MyMain6.cpp。在程序中,定义了一个Furniture类,Bed类和Sofa类是在Furniture类的基础上按公有继承的方式产生的派生类,Sleepersofa类是在Bed类和Sofa类的基础上按公有继承的方式产生的派生类。
请按要求完成下列操作,将类Date的定义补充完成:
①Bed类是在Furniture类的基础上按公有继承的方式产生的派生类,为了使程序中的多重继承关系不出现二义性。请在注释“//**1**”之后添加适当的语句。
②Sofa类是在Furniture类的基础上按公有继承的方式产生的派生类,为了使程序中的多重继承关系不出现二义性。请在注释“//**2**”之后添加适当的语句。
③Sleepersofa类是在Bed类和Sofa类的基础上按公有继承的方式产生的派生类。请在注释“//**3**”之后添加适当的语句。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
源程序文件MyMain6.cpp清单如下;
//MyMain6.cpp
#include<iostream>
using namespace std;
class Furniture

public:
Furniture( )
void setweight(int w)

weight=w;

int getweight( )

return weight;

protected:
int weight;
;
//* *1 * * class Bed definition

public:
Bed( )
void sleep( )

cout<<"sleeping..."<<end1;


//* *2* * class Sofa definition

public:
Sofa( )

[简答题]使用VC6打开考生文件夹下的工程RevProj8。此工程包含一个源程序文件 RevMain8.cpp。在该文件中,函数resort的功能是:能在一个数列中,对从指定位置开始的几位数,按相反顺序重新排列,并在主函数中输出新的序列。
请改正程序中的错误,使它能得到正确结果。
注意,不要改动main函数,不得删行或增行,也不得更改程序的结构。
源程序文件RevMain8.cpp中的程序清单如下:
//RevMain8.cpp
#include <instream>
using namespace std;
void resort(int arr[],int where,int amount);
int main ( )

int number [20] ,where, arrount, i;
cout<<"Input 20 numbers/n";
for (i=0; i<20; i++)
cin>>number [i];
cout<<"How many do you want to sort: ";
cin>>arrount;
cout<<"/n where do you want to start: ";
cin>>where;
cout<<"old array as follow:/n";
for (i=0; i<20; i++)
cout<<nmuber [i] <<" ";
resort (number,where, arrount);
cout<<"/n resorted array as follow:/n";
for (i=0; i<20; i++)
cout<<number [i] <<" ";
cout<<end1;
return 0;

void resort(int array[],in
[简答题]使用VC6打开考生文件夹下的工程RevPrroj7。此工程包含一个源程序文件 RevMain7.cpp。在该文件中,函数fun( )的功能是:逐个比较a、b两个字符串对应位置中的字符,把ASCII码值大或相等的字符依次存放到c数组中,形成一个新的字符串。例如:若a中的字符串为aBCDeFgH,b中的字符串为ABcd,则c中的字符串为 aBcdeFgH。
请改正程序中的错误,使它能得到正确结果。
注意,不要改动主函数,不得删行或增行,也不得更改程序的结构。
源程序文件RevMain7.cpp中的程序清单如下:
//RevMain7.cpp
#include<iostream>
#include<string>
using namespace std;
void fun(char *p,char *q,char *c)

int k=1;
while(*p!=*q)

if(*p<*q)
c[k]=*q;
else
c[k]=*p;
if(*p)
p++;
if(*q)
q++;


int main( )

char a[10]="aBCDeFgH",b[10]="ABcd",c[80]=’/0’;
fun(a,b,c);
cout<<"The string a is "<<a<<’/n’;
cout<<"The string b is "<<b<<’/n’;
cout<<"The string c is "<<c<<endl;
return 0;

[简答题]使用VC6打开考生文件夹下的工程RevProj10。此工程包含一个源程序文件RevMain10.cpp。在该文件中,函数fun的功能是:计算出数组x中的最小值与次最小值,并分别将其与x[0]、x[1]交换。
请改正程序中的错误,使它能得到正确结果。
注意,不要改动主函数,不得删行或增行,也不得更改程序的结构。
源程序文件RevMain10.cpp中的程序清单如下:
//RevMain10.cpp
#include <iostream>
using namespace std;
#define N 30
int fun(int *x, int n);
int main ( )

int h[N]=4,7, 6, 5, 1, 7,3, 8,0,2,3;
int i;
for (i=0; i<11; i++)
cout<<h [i] << " " ;
cout <<"/n";
fun(h, 11);
for (i=0; i<n; i++)
cout<<h [i]<<" ";
cout<<’ /n’;
return 0;

int fun(int *x, int n)

int i,t;
int a1=0, a2=0,min1=32767,min2=32676;
/* * * * *FOUND * * * * */
for(i=1;i<n;i++)

if (x [i]<min1)

min2=min1;
a2=a1;
min1=x [i];
a1=i;

else if (x [i] <min2)

[简答题]使用VC6打开考生文件夹下的工程RevProj12。此工程包含一个源程序文件RevMain12.cpp,但在该程序中有错误。请改正程序中的错误,使它能得到正确结果。
注意:不得删行或增行,也不得更改程序的结构。
源程序文件RevMain12.cpp中的程序清单如下:
//RevMain12.cpp
#include<iostream>
/* * * * FOUND * * * * */
using namespace std;
class test

private:
const int value;
char dep[10];
public:
/* * * * *FOUND* * * * */
test( )

value=0;
strcpy(dep,"m");

/* * * * *FOUND* * * * */
test(int newvalue)

value=newvalue;
strcpy (dep, "m");

/* * * * *FOUND * * * * */
void show( )

cout<<"value= "<<value<<end1;

;
int main ( )

test t1;
const test t2;
t1.show ( );
t2.show( );
return 0;

[简答题]使用VC6打开考生文件夹下的工程RevProj3。此工程包含一个源程序文件 RevMain3.cpp。阅读文件中的程序代码,找出程序中的错误,并改正。
源程序文件RevMain3.cpp清单如下:
//RevMain3.cpp
#include<iostream>
using namespace std;
class MyClass
public:
/* * * * * * * * *found * * * * * * * * * */
void MyClass(int a) value=a;
int Max(int x,int y)

if(x>y)
return x>yx:y;
else
return y>valuey:value;

/* * * * * * * * *found * * * * * * * * * */
~MyClass(int a)

value=a;

private:
int value;

int main( )

MyClass my(10);
cout<<my.Max(20,30)<<end1;
return 0;

[简答题]使用VC6打开考生文件夹下的工程RevProj14。此工程包含一个源程序文件RevMain14.cpp,但该程序中类的定义有错误。请改正程序中的错误,使它能得到正确结果。 注意,不要改动main函数,不得删行或增行,也不得更改程序的结构。 源程序文件RevMain14.cpp中的程序清单如下: //RevMain14.cpp #include<iostream> #include<math> using namespace std; class Point { private: double x; double y; public: Point( ){} void Point(double x1,double y1) { x=x1; y=y1; } void setvalue(double x,double y) { x=x; y=y; } double getx ( ) { return x; } double gety( ) } return y; } void print( ) { cout<<"x="<<x<<",y= "<<y<<end1; } ~Point( ){} }; class Line { private: Point p1; Point p2; double width; public: Line(double x1,double y1,double x2,double y2,double d) :p1(x1,y1),p2(x2,y2) { width=d; } ~Line( ){} void displength( ) { double 1; 1=sqrt((p1.getx{)-p2.getx( ))*(p1.getx( )-p2-getx( ))+ (p1.gety( )-p2.gety( ))*(p1.gety
[简答题]使用VC6打开考生文件夹下的工程MyProj11。此工程包含一个源程序文件 MyMain11.cpp。程序中定义了3个类A、B和C,但类C的定义并不完整。 请按要求完成下列操作,将类的定义补充完成: ①类C是基类A和B公有派生来的。请在注释“//* *1* *”之后添加适当的语句。 ②完成构造函数C(int k)定义,采用初始化列表的方式使基类A私有成员a初始化为k-2,基类B的私有成员b初始化为k+2,类C的私有成员c初始化为k。请在注释“//* *2* *”之后添加适当的语句。 ③完成类Derived的成员函数disp( )的类体外的定义。函数disp( )中要分别显式调用基类A、B的disp( )函数,然后要输出私有成员c的值。请在注释“//* *3* *”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件MyMain11.cpp清单如下; //MyMain11.cpp #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i;} void disp( ) { cout<<a<<" , " } }; class B { private: int b; public: B(int j){ b=j;} disp ( ) { cout<<b<<", "; } }; //* * *1* * * { private: int c; public: //* * *2* * * void disp( ); }; void c::disp( ) { //* * *3* * * } int main ( ) { C obj(10); obj.d
[简答题]使用VC6打开考生文件夹下的工程RevProj11。此工程包含一个源程序文件RevMain11.cpp,但在源程序文件中有错误。请改正程序中的错误,使它能得到正确结果。 注意,不得删行或增行,也不得更改程序的结构。 源程序文件RevMainll.cpp中的程序清单如下: //RevMainll.cpp #include<iostream> using namespace std; class point { private: const int color; int x; int y; public: point(int x,int y,int c) { this->x=x; this->y=y; color=c; } void show( ) { cout<<"x="<<x<<",y="<<y<<",color="<<color<<end1; } }; int main( ) { const point p(10,10,100); p.show( ); return 0; }

我来回答:

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

订单号:

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