计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分的程序。函数func(int A[NUM],int n)实现的功能是将数组的内容进行一次重新排序。排序的方法是:给定n,则下标为i的数字与下标为n-i的数字交换。从0开始,交换N/2次,则最后的内容为排序后的结果。 如果:A[8]={1,2,3,4,5,6,7,8},n=6,则结果:A[8]={7,6,5,4,3,2,1,8}。 注意:不能修改其他代码。#include<iostream.h>#define NUM 8void func(int A[NUM],int n){}int main(){ int A[NUM]={1,2,3,4,5,6,7,8}; func(A,6); for(int i=0;i<sizeof(A)/sizeof(int);i++) { cout<<A[i]<<' '; } cout<<endl; return 0;}
进入题库练习
问答题请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。其中有向量基类VectorBase、向量类Vector和零向量类ZeroVector的定义。请在程序中的画线处填写适当代码,然后删除横线,以实现上述定义。此程序的正确输出结果应为: (1,2,3,4,5) (0,0,0,0,0,0) 注意:只能在画线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动//************found************。 //源程序 #include<iostream> using namespace std; class VectorBase //向量基类,一个抽象类 int len, public: VectorBase(int len): len(len) int length() const return len; //向量长度,即向量中元素的个数 virtual double getElement(int i) const=0; //取第i个元素的值 virtual double sum() const_0; //求所有元素的和 void show() const //显示向量中所有元素 cout<<"("; for(int i=0;i<length()-1;i++) cout<<getElement(i)<<","; //************found************ cout<<________<<")"<<endl; //显示最后一个元素 ; class Vector: public VectorBase//向量类 double*val, public: Vector(int len, double v[]=NULL): VectorBase(len) val=new double[len]; for(int i=0; i<len, i++) val[i]=(v==NULL?0.0:v[i]); //************found************ ~Vector()______; double getElement(int index) const return val[index]; double sum() const double s=0.0: //************found************ for(int i=0; i<length();i++)______; return s: ; class ZeroVector: public VectorBase//零向量类 public: ZeroVector(int len): VectorBase(len) //************found************ double getElement(int index) const______; double sum()const return 0.0, ; int main() VectorBase*v: double d[]=1,2,3,4,5; v=new Vector(5,d); v->show(); delete v: v=new ZeroVector(6); v->show(); delete v: return 0:
进入题库练习
问答题写出下列程序的运行结果。 #include <iostream> using namespace std; class MyClass { public: MyClass(); ~MyClass(); void SetValue(int val); private: int i, }; MyClass::MyClass() :i(0) { cout << "This is a constructor! i=" << i << endl; } MyClass:: ~MyClass() { cout << "This is a destructor! i=" << i << endl; } void MyClass::SetValue(int val) { i=val; cout << "i=" << i << endl; } int main() { MyClass *my[3]; int k; for (k=0;k<3;k++) my[k]=new MyClass; for (k=0;k<3;k++) delete my[k]; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成函数fun(int x),该函数功能是将x的值转换成二进制数输出到屏幕,并且在函数中调用写函数WriteFile()将结果输出到modi2.txt文件中。 例如:x=13,13的二进制数字为1101,则输出到屏幕的为1101。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 #include #include #include using namespace std; Void WriteFiie(char*str) { ofstream out1; out1.open("modi2.txt",ios base::binary | ios_base::app); for(int i=0;str[i]!=0;i++) out1.put(str[i]); out1.Close(); } Void fun(int x) { } void ClearFile() { ofstream out1; out1.open("modi2.txt"); out1.close(); } int main() { ClearFile(); fun(13); return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,此工程中包含一个源程序文件main.cpp,其中有类Book(“书”)和主函数main的定义。程序中位于每个“//ERROR****found****”下的语句行有错误,请加以改正。改正后程序的输出结果应该是: 书名:C++语句程序设计总页数:299 已把“C++语言程序设计”翻到第50页 已把“C++语言程序设计”翻到第51页 已把“C++语言程序设计”翻到第52页 已把“C++语言程序设计”翻到第51页 已把书合上。 当前页:0 注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。 #include<iostremn> using namespace std; class Book{ char*title; int num_pages;//页数 int cur_page;//当前打开页面的页码,0表示书未打开 public: //ERROR **********found********** Book(const char*theTitle,int pages)num_pages(pages) { tide=new char[strlen(theTitle)+1]; strcpy(title,theTitle); cout<<endl<<"书名:"<<tide <<"总页数:"<<num_pages: } ~Book(){delete[]title;} bool isClosed()const{return cur_page==0;}//书合上时返回true,否则返回false bed isOpen()const{return ! isClosed();}//书打开时返回true,否则返回fasle int numOfPages()const{return num_pages;}//返回书的页数 int currentPage()const{return cur_page;}//返回打开页面的页码 //ERROR **********found********** void openAtPage(int page_no)const{ //把书翻到指定页 cout<<endl: if(page_no<1 || page_no>num_pages){ cout<<"无法翻到第"<<cur_page<<"页。"; close(); } else{ cur_page=Page_no; cout<<"已把“"<<title<<"”翻到第"<<cur_page<<"页"; } } void openAtPrevPage(){openAtPage(cur_page-1);}//把书翻到上一页 void openAtNextPage(){openAtPage(cur_page+1);}//把书翻到下一页 void close(){ //把书合上 cout<<endl: if(isClosed()) cout<<"书是合上的。"; else{ //ERROR **********found********** Bum_pages=0; cout<<"已把书合上。"; } cout<<endl: } }; int main(){ Book book("C++语言程序设计",299); book.openAtPage(50); book.openAtNextPage(); book.openAtNextPage(); book.openAtPrevPage(); book.close(); cout<<"当前页:"<<book.currentPage()<<endl; return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,其中包含类Myaass的定义。程序中位于每个“//ERROR ****found****”下的一行语句有错误,请加以更正。更正后程序的输出结果应该是: The value is 5 The value is 10 注意:只修改每个“//ERROR ****found****”下的那一行,不要改动程序中的其他内容。 #include <iostream> using namespace std; class MyClass { public: // ERROR ********** found********** voidMyClass() {value = 0;} // ERROR ********** found********** void setValue(int val) const { value=val; } int getValue() const { return value; } private: //ERROR **********found********** int value=0; }; int main() { MyClass obj; obj.setValue(5); cout << "The value is" << obj. getValue() << endl; obj.setValue(10); cout << "The value is" << obj. getValue() << endl; return 0; }
进入题库练习
问答题使用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 *department; int code; public: //**3** department=d; code=c; ; class teacher:public person char *department; char *level; public: teacher() void setinf(char *n,int a,char *d,char *1) //**4** department=d; level=1; ; void main() student s1("蒋军",23,"计算机学院",2); teacher t1; t1.setinf("刘雷",45,"计算机学院","教授");
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。程序通过继承关系,实现对姓名的控制。类TestClass1实现对名字访问的接口,TestClass2实现对名字的设置和输出。 程序输出为: TestClass2Name May 其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)在类TestClass1中定义接口函数GetName,为纯虚函数。请在注释//********1********后添加适当的语句。 (2)函数GetName2()实现获得名字的缓存,但是只获得读允许操作这个缓存,请在注释//********2********后添加适当的语句。 (3)实现TestClass2的构造函数,请在注释//********3********后添加适当的语句。 (4)完成TestClass2的构造函数,实现对名字的处理。请在注释//********4********后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>Class TestClass1{public: //********1********};class TestClass2:public TestClass1{public: Void GetName() { cout<<"TestClass2Name"<<endl; } //********2******** { return m str; } //********3******** { int i; for(i=0;str[i]!=0;i++] m str[i] = str[i]; //********4******** }private: char m str[32];};Void main(){ TestC2assl*p; TestClass2 obj1("Hay"); P=&obj1; P->GetName(); cout<<obj1.GetName2()<<end2; return;}
进入题库练习
问答题使用VC6打开考生文件夹下的工程test21_3,此工程包含一个源程序文件test21_3.cpp,其中定义了用于表示长方形的类CRectangle,但类CRectangle的定义并不完整。请按要求完成下列操作,将类CRectangle的定义补充完整。 (1)定义CRectangle的构造函数,函数含参数dx,dy,da和db,它们都是double型的数据,请将类数据成员x,y, a和b初始化,并输出“CRectangle Constructed.”(另起一行输出该文字)。请在注释“//**1**之后添加适当的语句。 (2)完成类CRectangle的成员函数getperimeter()的定义,将以a和b为边的矩形周长的值返回,请在注释“//**2**”之后添加适当的语句。 (3)完成类CRectangle的成员函数getarea()的定义,将以a和b为边的矩形面积的值返回,请在注释“//**3**”之后添加适当的语句。 (4)完成类CRectangle的友元函数friend double dist(CRectangle double y; double a; double b; public: CRectangle() { cout<<"/nCRectangle Constructed."<<endl; } CRectangle(double dx, double dy, double da, double db) { //**1** a=da; b=db; cout<<"/nCRectangle Constructed."<<endl; } ~CRectangle ( ) { cout<<"CRectangle Destructed."<<endl; } void putxy(double dx, double dy){ x=dx; y=dy;} void putab(double da, double db)( a=da; b=db;} double getx(){ return x;} double gety(){ return y;} double geta(){ return a;} double getb(){ return b;} double getperimeter() { //**2** } double getarea() { //**3** } friend double dist(CRectangle }; double dist(CRectangle return sqrt(tx*tx+ty*ty); } void main() { CRectangle rect; rect.putxy(100.0, 50.0); rect.putab(1200.0, 700.0); cout<<"Down_Left corner point is: ("<<rect.getx() <<", "<<rect.gety()<<")" <<endl; cout<<"a= "<<rect.geta()<<", b="<<rect.getb() <<endl; cout<<"Perimeter of this rectangle is: "<<rect.getperimeter()<<endl; cout<<"Area of this rectangle is:"<<rect.getarea()<<endl; cout<<"The Distance is:"<<dist(rect)<<endl; CRectangle recta(200,150,2000,800); cout<<"Down_Left corner point is:("<<recta.getx()<<","<<recta.gety()<<")"<<endl; cout<<"a="<<recta.geta()<<", b="<<recta.getb()<<endl; cout<<"Perimeter of this rectangle is: "<<recta.getperimeter()<<endl; cout<<"Area of this rectangle is: "<<recta.getarea()<<endl; cout<<"The Distance is :"<<dist(recta)<<endl; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹pmj1下的工程pmjl,此工程中含有一个源程序文件pmj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: This object is no.1 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。//proj1.cpp#include<iostream>using namespace std;class NyClass{public: NyClass():count(0){cout<<”This object is”;)//ERROR********found******** void Inc()const {tout<<”no.”<<++count<<end1;}private://ERROR********found******** int count=0; }; int main() { NyClass*obj=new NyClass; //ERROR********found******** *obj.Inc(); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。程序的功能是寻找1~500以内的亲和数并显示出来,函数amicableNum(int m,int n)判定两个数是否是亲和数。 亲和数的定义为:两个数m和n,如果n的所有因子之和(因子除掉自身)等于m,且m的所有因子等于n,则m、n是互为亲和数。 注意:不能修改程序的其他部分,只能补充amicableNum(int m,int n)函数。 #include int amicableNum(int n) { int sum=0; for(int i=1;i
进入题库练习
问答题使用VC6打开考生文件夹下的工程MyProj5。此工程包含一个源程序文件 MyMain5.cpp,其中定义了用于表示日期的类Date,但类Date的定义并不完整。请按要求完成下列操作,将类Date的定义补充完成: ①定义私有数据成员length、width和labe1,其中length、width是int型,labe1是类point的对象。它们分别表示长方形的长、宽以及坐标点。请在注释“//**1**”之后添加适当的语句。 ②完成构造函数square的定义,使square对象的默认值为:length=0,width=0, label(0,0),请在注释“//**2**”之后添加适当的语句。 ③完成重载构造函数square(int l,int w,int x,int y)的定义,把数据成员length、width和对象labe1分别初始化为参数l、w、x和y的值,请在注释“//**3**”之后添加适当的语句。 ④完成成员函数get_area()的类外定义,此函数的功能是返回此长方形的面积,及返回length*width的值。请在注释“//**4**”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件MyMain5.cpp清单如下: //MyMain5.cpp #include<iostream> using namespace std; class point private: int x,y; public: void set (int i,int j) x=i; y=j; int get_y () return y; ; class square //* * 1 * * public: //* * 2 * * square(int l,int w, int x, int y) //* * 3 * * void set(int l,int w) length=1; width=w; int get_area() const return length*width; ; int square::get_area() const //* * 4 * * int main() square small(2,4,1,35); cout<<small.get_area()<<end1; return 0;
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,该工程中包含一个程序文件main.cpp,其中有类CPolygon(“多边形”)、CRectangle(“矩形”)、CTriangle(“三角形”)的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义。该程序的正确输出结果应为: 20 10 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 #include<iostream> using namespace std; class CPolygon{ public: //********found******** ______//纯虚函数area声明 void printarea(void) //********found******** {cout<<______<<endl;} }; class CRectangle: public CPolygon{ int width; //长方形宽 int height; //长方形高 public: CRectangle(int w, int h): width(w), height(h){} int area(void) {return(width*height); } }; class CTriangle: public CPolygon{ int length; //三角形一边长 int height; //该边上的高 public: CTriangle(int 1, int h): length(1), height(h){} //********found******** int area(void){return(______)/2;) }; int main(){ CRectangle rect(4, 5); CTriangle trgl(4, 5); //********found******** ______*ppoly1, *ppoly2; ppoly1= ppoly2= ppoly1->printarea(); ppoly2->printarea(); return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程proj3,其中包含源程序文件main.cpp和用户定义的头文件Array.h,整个程序包含有类Array的定义和主函数main的定义。请把主程序文件中的Array类的成员函数MinTwo()的定义补充完整,经修改后运行程序,得到的输出结果应为: 8 29,20,33,12,18,66,25,14 12.14 注意:只允许在“//********333********”和“//********666********”之间填写内容,不允许修改其他任何地方的内容。 //Arry. h #include <iostream> #include <cstdlib> using namespaee std; template <class Type> class Array { //数组类 public: Array(Type b[], int mm): size (mm) { //构造函数 if(size<2) {cout <<"数组长度太小, 退出运行!"; exit(1); } a=new Type[ size]; for(int i=0; i<size; i++) a[i]=b[i]; } ~Array() {delete [ ]a;} //析构 void MinTwo (Type //由x1和x2带回数组a中最小的两个值 int Length() const{ return size; } Type operator [] (int i)const { //下标运算符重载为成员函数 if (i<0 || i>=size) {cout<<"下标越界!" <<endl; exit (1);} return a[i]; } private: Type * a; int size; }; void writeToFile(const char * ); //不用考虑此语句的作用 //main. cpp #include "Array. h" template <class Type> void Array <Type>::MinTwo (Type //******** 333******** //******** 666******** } int main () { int s1[8]={29, 20, 33, 12, 18, 66, 25, 14}; Array<int> d1 (s1, 8); int i, a, b; d1.MinTwo (a, b); cout <<d1.Length() <<endl; for(i=0; i<7; i++) cout <<d1[i]<<", "; cout <<d1[7] <<endl; cout <<a<<", "<<b<<endl; writeToFile (""); return 0; }
进入题库练习
问答题综合应用题 使用VC6打开考生文件夹下的工程kt10_3,此工程包含一个源程序文件kt10_3.cpp,其中定义了用于表示雇员信息的CEmployee类与表示公司信息的Company类,但这两个类的定义并不完整。请按要求完成下列操作。 (1)定义Cemployee类的私有数据成员name(大小为50的字符数组)和pay(double型数据),分别用于记录雇员姓名和月薪。请在注释“//**1**”之后添加适当的语句。 (2)完成Company类默认构造函数的定义,该构造函数将n值赋值给私有成员num,并完成指针emp所指的n个Cemployee对象空间的申请,请在注释“//**2**”之后添加适当的语句。 (3)完成Company类成员函数voidCompany::add(intcode,charname[50],doublepay)的定义,该函数将某一雇员的编号code、姓名name及月薪pay输入到公司信息中。请在注释“//**3**”之后添加适当的语句。 (4)完成Company类成员函数voidCompany::print()的定义,使其以"_ispaid_RMBforonemonth"的格式输出公司内所有员工的月薪信息。请在注释“//**4**”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序清单如下: #include #include classCEmployee { public: voidputname(charn[50]){strcpy(name,n);} voidgetname(charn[50]){strcpy(n,name);} voidputpay(doubled){pay=d;} doublegetpay(){returnpay;} private: //**1** }; classCompany { private: CEmployee*emp; intnum; public: Company(intn); voidadd(intcode,charname[50],doublepay); voidprint(); }; Company::Company(intn) { //**2** } voidCompany::add(intcode,charname[50],doublepay) { //**3** } voidCompany::print() { //**4** for(inti=0;igetname(c); money=(emp+i)->getpay(); cout<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行有问题,请改正main函数中的错误,使程序的输出结果是: 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>#include<iomanip.h>Void main() { int a[3][3]={{1,2,3},{4,5,6},{7,8,9}}; int*p,i; //********error******** p=a; for(i=0;i<9;i十+){ cout<<setw(2)<<*(p+i); //********error******** cout<<setw(2)<<*(a+i); if(i%3==2)cout<<endl; }}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2。该工程中包含一个程序文件main.epp,其中有类Quadritic、类Root及主函数main的定义。一个Quadritic对象表示一个ax 2 +bx+c的一元二次多项式。一个Root对象用于表示方程ax 2 +bx+C=0的一组根,它的数据成员num_of_roots有3种可能的值,即0、1和2,分别表示根的3种情况:无实根、有两个相同的实根和有两个不同的实根。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为(注:输出中的X^2表示x 2 ): 3X^2+4X+5=0.0 无实根 4.5X^2+6X+2=0.0有两个相同的实根:一0.666667和一0.666667 1.5X^2+2X一3=0.0有两个不同的实根:0.896805和一2.23014 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 #include #include #include using namespace std; class Root{ //一元二次方程的根 public: const double x1; //第一个根 const double x2; //第二个根 const int num of roots;//不同根的 数量:0、1或2 //创建一个“无实根”的Root对象 Root():x1(0.0),x2(0.0),num of roots(0){) //创建一个“有两个相同的实根”的Root 对象 Root(double root) //**********found********** :________{} //创建一个“有两个不同的实根”的Root对象 Root(double rootl,double root2):xl (rootl),x2(root2),num of roots(2){) void show()const{ //显示根的信息 cout
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程pwj1,此工程中含有—个源程序文件projl.cpp。其中位于每个注释“//ERROR**********found**********”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: NUM=0 Value=1 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。//proj1.cpp#include<iostream>using namespace std;class MyClass{ int i; friend void Increment(MyClas S&f);public: const int NUM;//ERROR********found******** MyClass(int i=0){NUM=0; i=i; } int GetValue()const{return i;)};//ERROR********found********VOid Increment(){f.i++;)int main(){ MyClass obj;//ERROR********found******** MyClass::Increment(obj); cout<<”NUM=”<<obj.NUM<<endl <<”Value:”<<obj.GetValue()<<end1 return 0;}
进入题库练习
问答题综合应用题 使用VC6打开考生文件夹下的工程test18_3,此工程包含一个源程序文件test18_3.cpp,其中定义了用于表示雇员的类Employee,但类Employee的定义并不完整。请按要求完成下列操作,将类Employee的定义补充完整。 (1)补充类Employee的构造函数,请使用字符串函数将数据成员name、address、city、province和zipcode分别初始化为参数*nm,*addr,*city,*prov和*zip的值。请在注释"//**1**"之后添加适当的语句; (2)完成类Employee的成员函数ChangeName(char * newName)的定义,将newName指向的内容赋值给数据成员name,请在注释"//**2**"之后添加适当的语句; (3)完成类Employee的成员函数Display()的定义,先使用指针buffer动态申请一个char型的200单位大小的空间,然后使用字符串函数将数据成员name和address依次复制其中,最后返回该指针buffer,将请在注释"//**3**"之后添加适当的语句。输出结果如下: 王东建国路大街105号 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件test18_3.cpp清单如下: #include #include class Employee{ protected: char name[20]; char address[100]; char city[20]; char province[20]; char zipcode[10]; public: Employee(char *nm,char *addr,char *city, char *prov, char *zip); void ChangeName(char * newName); char *Display(); }; Employee::Employee(char *nm, char *adr, char *cit, char *prov, char *zip) { //**1** strcpy(city,cit); strcpy(province,prov); strcpy(zipcode,zip); } void Employee::ChangeName(char * newName) { //**2** } char *Employee::Display() { //**3** strcat(buffer, address); return buffer; } void main() { Employee emp("李华","建国路大街105号","石家庄","河北","103400"); emp.ChangeName("王东"); cout<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: m=一10 n=一10 p=0 q=—10 z=A 注意:错误的语句在∥********4********的下面,修改该语句即可。 #include void msin() { double m=1 0; float n=1 0; bool P=1; int q=10; char z=‘a’; m=一m; ∥********error******** n=~n; ∥********error******** p=一P; ∥********error******** q=~q; z=z一32; cout<<“m=”<
进入题库练习