计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
进入题库练习
进入题库练习
进入题库练习
进入题库练习
进入题库练习
请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中声明了MiniComplex是一个用于表示复数的类。请编写这个operator+运算符函数,以实现复数的求和运算。两个复数的和是指这样一个复数:其实部等于两个复数的实部之和,其虚部等于两个复数的虚部之和。例如,(23+34i)+(56+35i)等于(79+69i)。 要求: 补充编制的内容写在“//**********333**********”与“//**********666**********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。//Minicomplex.h#includeiostreamusing namespace std;class MiniComplex//复数类{public: //重载流插入和提取运算符 friend ostreamoperator(ostream osObject, const MiniComplexcomplex) { osObject"("complex.realPart"+"complex.imagPart"i"")"; return osObject; } friend istreamoperator(istreamisObject,MiniComplexcomplex) { char ch; isObjectcomplex.realPartchcomplex.imagPartch; return isObject; } MiniComplex(double real=0,double imag=0);//构造函数 MiniComplex operator+(const MiniComplexotherComplex)const;//重载运算符+private:double realPart;//存储实部变量double imagPart;//存储虚部变量};void writeToFile(char*);//main.cpp#include"MiniComplex.h"MiniComplex::MiniComplex(double real,double imag){realPart=real;imagPart=imag;}MiniComplex MiniComplex::operator+(const MiniComplexother-Complex)const{//**********333**********//**********666**********}int main(){ void writeToFile(char*); MiniComplex num1(23,34),num2(56,35); cout"Initial Value of Num1="num1"\nInitial Value of Num2="num2endl; coutnum1"+"num2"="num1+num2endl;//使用重载的加号运算符 writeToFile(""); return 0; }
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj1,该工程含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: The value is 10 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 1 //proj1.cpp 2 #includeiostream 3 using namespace std; 4 class MyClass{ 5 int value; 6 public: 7 //ERROR ****found**** 8 void MyClass(int val):value (val){} 9 int GetValue()const{return value;} 10 void SetValue(int val); 11 }; 12 //ERROR ******found****** 13 inline void SetValue(int val) 14 {value=val;} 15 int main() 16 { 17 MyClass obj(0); 18 obj.SetValue(1 0); 19 //ERROR ******found****** 下列语句功能是输出obj的成员value的值 20 cout"The value is" obj.valueendl; 21 return 0; 22 }
进入题库练习
请打开考生文件夹下的解决方案文件proj3,此工程中包含一个源程序文件proj3.cpp,补充编制C++程序proj3.cpp,其功能是读取文本文件in.dat中的全部内容,将文本存放到doc类的对象myDoc中。然后将myDoc中的字符序列反转,并输出到文件out.dat中。文件in.dat的长度不大于1000字节。 要求: 补充编制的内容写在“//********333********”与“//********66666********”两行之间。实现将myDoc中的字符序列反转,并将反转后的序列在屏幕上输出。不得修改程序的其他部分。 注意:程序最后已将结果输出到文件out.dat中,输出函数writeToFile已经给出并且调用。 1 //proj3.cpp 2 #includeiostream 3 #includefstream 4 #includecstring 5 using namespace std; 6 7 class doc 8 { 9 private: 10 char*str;//文本字符串首地址 11 int length;//文本字符个数 12 public: 13 //构造函数,读取文件内容,用于初始化新对象,filename是文件名字符串首地址 14 doc(char*filename); 15 void reverse();//将字符序列反转 16 ~doc(); 17 void writeToFile(char*filename); 18 }; 19 doc::doc(char*filename) 20 { 21 ifstream myFile(filename); 22 int len=1001,tmp; 23 str=new char[len]; 24 length=0 ; 25 while((tmp=myFile.get())!=EOF) 26 { 27 str[length++]=tmp; 28 } 29 str[length]='\0'; 30 myFile.close(); 31 } 32 void doc::reverse(){ 33 //将数组str中的length个字符中的第一个字符与最后一个字符交换,第二个字符与倒数第二个 34 //字符交换…… 35 //***************333*************** 36 37 38 //***************666*************** 39 } 40 41 doc::~doc() 42 { 43 delete[]str; 44 } 45 void doc::writeToFile(char*filename) 46 { 47 ofstream outFile(filename); 48 outFilestr; 49 outFile.ciose(); 50 } 51 void msin() 52 { 53 doc myDoc("in.dat"); 54 myDoc.reverse(); 55 myDoc.writeToFile("out.dat"); 56 }
进入题库练习
进入题库练习
使用VC6打开考生文件夹下的源程序文件modi3.cpp。此程序的运行结果为: In CDerive's display().b=1 In CDerive2’s display().b=2 其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)定义函数display()为无值型纯虚函数。请在注释∥********1********之后添加适当的语句。 (2)建立类CDerive的构造函数,请在注释∥********2********之后添加适当的语句。 (3)完成类CDerive2成员函数diaplay0的定义。请在注释∥********3********之后添加适当的语句。 (4)定义类Derivel的对象指针d1,类CDerive2的对象指针d2。其初始化值分别为1和2。请在注释∥********4********之后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#includeiOStreamusing namespace std;Class CBase{public: CBase(int i){b=i;)∥********1********protected: int b; }; class CDerive:public CBase { public: ∥********2******** void di splay() { cout“In CDerive’s display().“”b=”bendl; } }; class CDerive2:public CBase { public: CDerive2(int i):CBaSe(i){} ∥********3********};void func(CBase*obj){ obj一di splay();}void main(){ ∥********4******** func(d1); func(d2);}
进入题库练习
进入题库练习
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR*********found**********”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:NUM=0Value=1注意:只修改注释“//ERROR****found****”的下一行语句,不要改动程序中的其他内容。//proj1.cpp#includeusing namespace std;class MyClass{int_i;friend VOid Increment;(MyClassf);public:const int NUN;//ERROR*******found*******NyClass(int i=0){NUM=0;_i=i;}int GetValue( )const{return_i;}};//ERROR*******found*******void Increment( ){f._i++;)int main( ){HyClass obj;//ERROR*******found*******NyClass::TncEement(ohj);coutretuEn0;}
进入题库练习
进入题库练习
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj1,其中有枚举DOGCOLOR、狗类Dog和主函数main的定义。程序中位于每个“//ERROR ****found****”下的语句行有错误,请加以改正。改正后程序的输出结果应该是: There is a white dog named Hobo. There is a black dog named Haha. There is a motley dog named Hihi. 注意:只修改每个“//ERROR ****found****”下的那一行,不要改动程序中的其他内容。#includeiostreamusing namespace std;//狗的颜色:黑、白、黄、褐、花、其他enum DOGCOLOR {BLACK, WHITE,YELLOW,BROWN,PIEBALD,OTHER);class Dog {//狗类 DOGCOLOR color; char name[20]; static int count;public: Dog(char name[],DOGCOLORcolor){ strcpy(this-name,name);//ERROR ********found******** strcpy(this-color,color); } DOGCOLOR getColor()const{return colOr;}//ERROR ********found******** const char* get;Name()const{return*name;} const char * getColor-string()const{ switch(color){ case BLACK: return "black"; case WHITE: return "white"; case YELLOW: return "yellow"; case BROWN: ret;uEll "brown"; case PTEBALD: return "piebald"; } return"motley"; } void show()const{ cout"There is a"get-Colorstring() " dog named "name'.'endl; }};int main(){//ERROR ********found******** Dog dogl("Hoho",WHITE),dog2("Haha",BLACK);dog3("Hihi",OTHER); dog1.show(); dog2.show(); dog3.show(); return 0;}
进入题库练习
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2。该工程中包含一个程序文件main.cpp,其中有“书”类Book及其派生出的“教材”类TeachingMaterial的定义,还有主函数main的定义。请在程序中“//*******found*******”下的横线处填写适当的代码,然后删除横线,以实现上述类定义和函数定义。此程序的正确输出结果应为: 教材名:C++语言程序设计 页 数:299 作 者:张三 相关课程:面向对象的程序设计 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#includeiostreamusing namespace std;class Book{ //“书”类 char*title; //书名 int num_pages;//页数 char*writer; //作者笔名public: Book(const char*the_title,int pages,const char*the_writer):num pages(pages){ title=new char[strlen(the title)+1]; strcpy(title,the_title); //***********found*********** strcpy(writer,the_writer); } //***********found*********** ~Book(){________} int numOfPages()const{returnnum_pages;}//返回书的页数 const char*theTitle()const{return title;)//返回书名 const char * theWriter()const{return writer;} //返回作者名}; class TeachingMaterial:public Book{//“教材”类 char*course;public: TeachingMaterial(const char*the title,int pages,const char*the_writer,const char*the_course)//***********found*********** :_________{: course=new char[strlen(the course)+1]; strcpy(course,the_course); } ~TeachingMaterial(){delete[]course;) const char * theCourse()const{return course;} //返回相关课程的名称};int main(){ TeachingMaterial a_book("C++语言程序设计”,299,"张三",“面向对象的程序设计”); cout"教材名:"a book.theTitle()endl "页 数:"a book.numOf-Pages()endl "作 者:"a book.the-Writer()endl //***********found***********"相关课程:"_________; coutendl; return 0;}
进入题库练习