题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-11-17 03:47:08

[简答题]请使用VC6或使用[答题]菜单打开考生文件夹projl下的工程proj1,该工程含有一个源程序文件proj1. cpp。其中位于每个注释“//ERROR **** found ****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:
The value is 10
注意:只修改注释“//ERROR ***** found ****”的下一行语句,不要改动程序中的其他内容。
// proj1, cpp
#include < iostream >
using namespace std;
class MyClass
int value ;
public :
// ERROR ******** found ********
void MyClass(int val) : value(val)
int GetValue( ) const return value;
void SetValue(int val) ;
;
//ERROR ******** found ********
inline void SetValue(int val) value = val;
int main( )
MyClass obj (0) ;
obj. SetValne(10) ;
//ERROR ******** found ******** 下列语句功能是输出obj的成员value的值
cout << "The value is " << obj. value << endl;
return 0 ;

更多"请使用VC6或使用[答题]菜单打开考生文件夹projl下的工程proj"的相关试题:

[简答题]请使用VC6或使用[答题]菜单打开考生文件夹projl下的工程proj1,此工程包含一个源程序文件proj1.cpp。其中位于每个注释“//ERROR****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:You are nght.
注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。
//proj1.cpp
#include <iostream>
using namespace std;
class MyClass

public:
MyClass(int x):number (x)
//ERROR **********found**********
~MyClass(int x)
//ERROR **********found**********
void Judge(MyClass &obj);
private:
int number;
void Judge(MyClass &obj)

if(obj.number==10)
cout<<"You are right."<<endl;else
cout<<"Sorry"<<endl;

int main( )

//ERROR **********found**********
MyClass object;
Judge(object);
return 0;

[简答题]请使用VC6或使用[答题]菜单打开考生文件夹projl下的工程proj1,其中有枚举DOGCOLOR、狗类Dog和主函数man的定义。程序中位于每个“//ERROR ****found****”下的语句行有错误,请加以改正。改正后程序的输出结果应该是:
There is a white dog named Hoho.
There is a black dog named Haha.
There is a motley dog named Hihi.
注意:只修改每个“//ERROR ****found****”下的那一行,不要改动程序中的其他内容。
#include <iostream>
using namespace std;
enum DOGCOLOR BLACK,WHITE,YELLOW,BROWN,PIEBALD,OTHER;
class Dog //狗类
DOGCOLOR color;
char name[20];
static int count;
public:
Dog(char name[],DOGCOLOR color)
strcpy(this->name,name);
strcpy(this->color,color);

DOGCOLOR getColor ( ) constreturncolor;
const char* getName ( ) const return * name;
const char * getColorString ( )const
switch (color)
case BLACK:return"black";
case WHITE:return"white";
case YELLOW:return"yellow";
case BROWN:return"brown";
case PIEBALD:return"piebald";

return"motley";

void show ( ) const
cout<<"
[简答题]请使用“答题"菜单或使用VC6打开考生文件夹proj1下的工程proj1,该工程含有一个源程序文件proj1.cpp。程序中位于每个//ERROR************found************下的语句行有错误。请改正这些错误,改正后程序的输出应该是:
1 2 3 4 5 6 7 8 9 10
注意:只修改注释//ERROR************found************下的一行语句,不要改动程序中的其他内容。
//源程序proj1.cpp
#include<iostream>
using namespace std;
class MyClass
public:
MyClass(int len)
array=new int[len];
arraySize=len;
for(int i=0;i<arraySize; i++) array[i]=i+l;

~MyClass( )
//ERROR************found************
delete array[];

void Print( ) const
for(int i=0;i<arraySize; i++)
//ERROR************found************
cin<<array[i]<<";
cout<<endl;

prlvate:
int*array;
int arraySize;

int main( )
//ERROR************found************
MyClass obj;
obj.Print( );
return 0:

[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,此工程包含一个源程序文件proj1.cpp。文件中将表示数组元素个数的常量Size定义为4,并用int类型对类模板进行了实例化。文件中位于每个注释“//ERROR****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:
1 2 3 4
注意:模板参数名用T。只修改注释“//ERROR ********found********”的下一行语句,不要改动程序中的其他内容。
//proj1.cpp
#include <iostream>
using namespace std;
//将数组元素个数 Size定义为4
//ERROR ********found********
const int Size;
template <typename T>
class MyClass

public:
MyClass(T*p)

for(int i=0;i<Size;i++)
array[i]=p[i];

void Print( );
private:
T array[Size];
;
template <typename T>
void MyClass::Print( )

for (int i=0;i<Size;i++)
cout<<array[i]<<’/t’;

int main( )

int intArray[Size]=1,2,3,4;
//ERROR ********found********
MyClass <double> obj(intArray);
obj.Print( );
cout<<endl;
return 0;

[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程包含一个源程序文件proj2.cpp。其中定义了Score类。
Score是一个用于管理考试成绩的类。其中,数据成员_s指向存储成绩的数组,_n表示成绩的个数;成员函数Sort使用冒泡排序法将全部成绩按升序进行排列。
请在程序中的横线处填写适当的代码,然后删除横线,以实现Score类的成员函数Sort。
注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。
//proj2.cpp
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
class Score
public:
Score(double * s, int n):_s(s),_n(n)
double GetScore (int i) const return_s[i];
void Sort ( );
private:
double*_s;
int_n;
;
void Score::Sort( )

for(int i=0;i<n-1;______)
//********found********
for(int j=______;j>i;j--)
if(_s[j]<_s[j-1])
//交换_s[j]和_s[j-1]double t=_s[j];
//********found********
______;
//********found********
______;


int main ( )

const int NUM=10;
double s[NUM];
srand(time (0));
for(int i=0;i<NUM;i++)
s[i]=double(rand ( ))/RAND M
[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程中含有一个源程序文件proj2.cpp。函数char * GetNum(char*src,char*buf)从src开始扫描下—个数字字符序列,并将其作为一个字符串取出放入字符串空间buf中。函数返回扫描的终止位置,如果返回NULL表示没有扫描到数字字符序列。
运行程序时,如果输入的一行字符序列是
ABC012XY2378MN274WS
则输出为:
Digit string 1 is 012
Digit string 2 is 378
Digit string 3 is 274
注意:只在横线处编写适当代码,不要删除或移动“//****found****”。
//proj2.cpp
#include <iostream>
using namespace std;
char*GetNum(char*src,char*buf)

while(*src!=’/0’)

if(isdigit(*src)break;

if (*src=="/0")
//********found********
______;
while(*src!=’/0’&& isdigit(*src)

//********found********
______;
buf++;
src++;

*buf=’/0’;
return src;

int main( )

char str[100l,digits[20];
cin.getline(str,100);
char*p=str;
int i=1;
while((p=GetNum(p,digits))!=NULL)

cout<<"Digit string "<<i<<"is "<<digits<<endl;
//********found********
______;<
[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,该工程中含有一个源程序文件proj2.cpp,请将堆栈类的定义补充完整。使程序的输出结果为:
The element of stack are:4 3 2 1
注意:请勿修改主函数main和其他函数中的任何内容,只在横线处编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。
//proj2.cpp
#include <iostream>
using namespace std;
const int Size=5;
class Stack;
class Item

public:
//**********found**********
Item(const int&val):______
//构造函数对item进行初始化
private:
int item;
Item* next;
friend class Stack;
;
class Stack

public:
Stack( ):top(NULL)
~Stack( );
int Pop( );
void Push(const int&);
private:
Item*top;
:
Stack::~Stack( )

Item*p=top,*q;
while(p!=NULL)

q=p->next;
//**********found**********
______;//释放p所指向的节点
p=q;


int Stack::Pop( )

Item* temp;
int ret;
//**********found**********
______;//使temp指向栈顶节点
ret=top->item;
top=top->next
[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:
Constructor called.
The value is 10
Copy constructor called.
The value is 10
Destructor called.
Destructor called.
注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。
//proj1.cpp
#include <iostream>
using namespace std;
class MyClass
public:
//ERROR **********found**********
MyClass(int i)
value=i;cout<<"Construc-tor called."<<endl;
//ERROR **********found**********
MyClass(const MyClass p)

value=p.value;
cout<<"Copy constructorcalled."<<endl;

void Print ( )
cout<<"The value is"<<value<<endl;
//ERROR **********found**********
void ~MyClass( )
cout<<"Destructor called."
<<endl;
private:
int value;
;
int main( )

MyClass obj1;
obj1.Print( );
MyClass obj2(obj1);
obj2.Print( );
return
[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程包含有一个源程序文件proj2. cpp,其中定义了Stack类和ArrayStack类。
Stack是一个用于表示数据结构“栈”的类,栈中的元素是字符型数据。Stack为抽象类,它只定义了栈的用户接口,如下所示:
公有成员函数 功能
push 入栈:在栈顶位置添加一个元素
pop 退栈:取出并返回栈顶元素
ArrayStack是Stack的派生类,它实现了Stack定义的接口。ArrayStack内部使用动态分配的字符数组作为栈元素的存储空间。数据成员maxSize表示的是栈的最大容量,top用于记录栈顶的位置。成员函数push和pop分别实现具体的入栈和退栈操作。
请在程序中的横线处填写适当的代码,然后删除横线,以实现上述功能。此程序的正确输出结果应为:
a, b, c
c, b, a
注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//**** found ****”。
// proj2, cpp
#include < iostream >
using namespace std;
class Stack
public :
virtual void push(char c) = 0;
virtual char pop( ) = 0;
;
class ArrayStack : public Stack
char * p;
int maxSize ;
int top ;
public :
ArrayStack( int s)
top = 0;
maxSize = s;
//******** found ********
p =______;

~ ArrayStack ( )

//******** found ********
______;

void push(char c)

[简答题]使用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;

我来回答:

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

订单号:

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