更多"使用VC6打开考生文件夹下的工程RevProj12。此工程包含一个源程"的相关试题:
[简答题]使用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打开考生文件夹下的工程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打开考生文件夹下的工程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打开考生文件夹下的工程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"<disp( );
/**********found**********/
b->disp( );
}
[简答题]使用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打开考生文件夹下的工程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打开考生文件夹下的工程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;
[简答题]使用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;
}