题目内容

鸡尾酒招待 ()自助晚餐

查看答案
更多问题

Which part of the building should a visitor go to if he wants to make a phone call?

请使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,其中有枚举DOGCOLOR、狗类Dog和主函数main的定义。程序中位于每个“//ERROR ****found****”下的语句行有错误,请加以改正。改正后程序的输出结果应该是: There is a white dog named Hoh0. 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 nalTle[],DOGCOLOR Color){ strCpy(this一>name,name); //ERROR**********found**********、 strCpy(this一>Color,Color); } 1 DOGCOLOR getColorConst{retum Color;} //ERROR**********found********** Const Char * 9etNameConst{return*finin9;} Const Char * 9etColorStringConst{ switCh(Color){ Case BLACK:return”blaCk“; Case WHITE:return”white”: Case YELLOW:return’"yellow”: Case BROWN:return”brown”; ease PIEBALD:return”piebald”: } return”motley”; } void showConst{ . Cout<<”There is a”<<getColorString<<”dog named’’<<name<<’.’<<endl; } }; int main{ //ERROR**********found********** Dog dogl(”Hoh0”,WHITE),dog2(”Haha”,BLACK);d0g3(”Hihi”,0THER); d091.show; dos2.show; dos3.show; return 0; }

清使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,此工程中包含了类Pets(“宠物”) 和主函数main的定义。程序中位于每个“//ERROR****found ****”之后的一行语句有错误,请加以改 正。改正后程序的输出结果应为: Name:sonny Type:dog Name:John Type:dog Name:Danny Typc:cat Name:John Type:dog 注意:只修改每个“//ERROR ****found ****”下的那一行,不要改动程序中的其他内容。 include<iostream> using namespace sm; enum Pets_type{d09,cat,bird,fish}; class Pets{ private: char *name; Pets_type type; public: Pets(const char *name=”sonny”,Pets_type type=dog); Pets&operator=(const Pets&s); ~Pets; void showeonst;}; Pets::Pets(eonst char$naIne,Pets_type type) //构造函数 { This ->name=new char[strlen(name)+1]; strcpy(this一>name,name); //ERROR *********found********* type=type; }{ Pets::~Pets//析构函数,释放name所指向的字符串 { //ERROR *********found********* name=’/0‘; } Pets&Pets::0perator=(const Pets&s){ if(&s==this)//确保不要向自身赋值 return *this; delete[]name; name=new char[strlen(S.name)+1];//ERROR *********found********* strcpy(this一>nmne,name); type=S.type: return *this;} void Pets::showconst cout<<“Name:”<<name<<”Type:”: Pets mypetl,mypet2(’’John”,dog);

请使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,该工程中包含程序文件main.epp,其中有类Door(“门”)和主函数main的定义。程序中位于每个“//ERROR****found ****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 打开503号门…门是锁着的,打不开。 打开503号门的锁…锁开了。 打开503号门…门打开了。 打开503号门…门是开着的,无须再开门。 锁上503号门…先关门...门锁上了。 注意:只修改每个“//ERROR***********found **********”下的那一行,不要改动程序中的其他内容。 include<iostream> using namespace std; class Door{ int Bum;//门号 bool closed;//true表示门关着 bool locked://true表示门锁着 public: Door(int nHm){ //ERROR***********found*********** nun=this一>ann: closed=locked=true: } bool isClosedconst{rehlrn closed;} //门关着时返回true,否则返回false bool isOpenedconst{return!closed;} //门开着时返回true,否则返回false b001 isLockedconst{retum locked;} //门锁着时返回true,否则返回false bool isUnlockedconst{return!locked;} //门未锁时返回true,否则返回false void open{ //开门 cout<<endl<<”打开”<<nnm<<”号门...”; //ERROR***********found*********** if(closed) cout<<”门是开着的,无须再开门。”; else if(10cked) cout<<”门是锁着的,打不开。”; else{ closed=false; eout<<”门打开了。”; } } void close{//关门 cout<<endl<<”关上”<<num<<”号门…”; if(closed) cout<<”门是关着的,无须再关门。”; else{ closed=true; cout<<”门关上了."; } } //ERROR************found************ void lockconst{//锁门 cout<<endl<<”锁上”<<num<<”号门…”; if(locked) cout<<”门是锁着的,无须再锁门。”; else{ if(!closed){ cout<<”先关门...”; closed=true; } locked=true: cout<<”门锁上了。”; } } wild unlock{//开锁 cout<<endl<<”开”<<num<<”号门的锁...”; if(!locked) cout<<”门没有上锁,无须再开锁。”; else{ locked=false; cout<<”锁开了。”; } }; int main{ Door door(503); door.open; door.unlock; door.open; door.open; floor.10ck; return 0; }

答案查题题库