题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-07-27 04:36:44

[简答题]使用VC6打开考生文件夹下的工程test4_3。此工程包含一个源程序文件test4_3.cpp,其对一个学校的教师和考生情况进行了描述。由于教师和考生之间有相同的信息,如姓名、年龄等,所以可抽象出一个基类person,考生类student和教师类teacher作为person类的派生类。请按要求完成下列操作,将程序中的类定义补充完整。
(1)定义基类person的私有数据成员name和age,分别用于表示姓名和年龄,name为字符指针,age为血型的数据。请在注释“//**1**”之后添加适当的语句。
(2)完成基类person的重载构造函数person(char *n,int a)的定义,把数据成员name,age分别初始化为参数n,a的值,请在注释“//**2**”之后添加适当的语句。
(3)根据主函数main中对s1的声明,定义派生类student的构造函数。在注释“//**3**”之后添加适当的语句。
(4)完成派生类teacher成员函数void setinf(ehar *n,int a,char *d,char *1)的定义,其功能为记录教师的姓名、年龄、院,系与职称信息。请在注释“//**4**”之后添加适当的语句。
输出结果如下:
刘雷(45)destructor
蒋军(23)destructor
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
源程序文件test4_3.cpp清单如下:
#include<iostream.h>
class person

//**1**
public:
person( )
person(char *n,int a)

//**2**

void setname(char *n)name=n;)
void setage(int a)age=a;
~person( )cout<<name<<"("<<age<<")destructor"<<endl;)
;
class student:public person

char *

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

[简答题]使用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打开考生文件夹下的工程test6_3,此工程包含一个源程序文件test6_3.cpp,其中定义了用于表示考生的类Student,请按要求完成下列操作,将程序补充完整。 (1)定义私有数据成员code、english分别用于表示考生的编号、英语成绩、它们都是int型的数据。请在注释"//**1**"之后添加适当的语句。 (2)完成成员函数void Student::inputinformation( )的定义,该函数用于用户输入一个考生对象的信息,输入格式如下所示: 输入编号: 英语成绩: 计算机成绩: 请在注释"//**2**"之后添加适当的语句。 (3)利用已实现的类Student的成员函数,完成函数void firstname(Student *A[],int num)的定义,该函数根据考生信息A[],输出num个考生中总分最高者的编号及其相应的总分,在此不考虑总分相同的情况。请在注释"//**3**"之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件test6_3.cpp清单如下: #include class Student { //**1** int computer; int total; public: void getinformation( ); void computesum( ); int getcode( ); int gettotalscore( ); ~Student( ); }; void Student::getinformation( ) { //**2** cout<<"英语成绩:"; cin>>english; cout<<"计算机成绩:"; cin>>computer; } void Student::computesum( ) { total=english+computer; cout<<"编号"<
[简答题]改错题 使用VC6打开考生文件夹下的工程test6_1,此工程包含一个源程序文件test6_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下: Constructor2 Constructor1 i=0 i=10 Destructor 源程序文件test6_1.cpp清单如下: #include class CSample { int i; public: CSample( ){cout<<"Constructor1"<查看答案
[简答题]使用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打开考生文件夹下的工程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;

[简答题]使用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打开考生文件夹下的工程RevProj15。此工程包含一个源程序文件RevMain15.cpp,但该程序中类的定义有错误。请改正程序中的错误,使它能得到正确结果。 注意,不要改动主函数,不得删行或增行,也不得更改程序的结构。 源程序文件RevMain15.cpp中的程序清单如下: //RevMain15.cpp #include<iostream> using namespace std; class Sample { private: int x; static int y; public: Sample(int a) { x=a; y+=x; } static void print(Sample s) { cout<<"x="<<x<<<<",y="<<y<<end1; } Sample::y=5; int main( ) { Sampel s1(10); Sample s2(15); Sample::print(s1); Sample::print(s2); 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 displ
[简答题]使用VC6打开考生文件夹下的工程RevProj13。此工程包含一个源程序文件RevMain13.cpp,但该程序中类的定义有错误。请改正程序中的错误,使它能得到正确结果。 注意,不要改动主函数,不得删行或增行,也不得更改程序的结构。 源程序文件RevMain13.cpp中的程序清单如下; //RevMain13.cpp #include<iostream> using namespace std; class MyClass { public: MyClass(int a=0,b=1); Print( ); private: int x; int y; }; MyClass::MyClass(int a=0,int b=1) { x=a; y=b; } void MyClass::Print( ) { cout<<"x="<<x<<end1; cout<<"y= "<<y<<end1; } int main( ) { MyClass obj(1,2) obj.Print( ); return 0; }

我来回答:

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

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码