问答题使用VC++6.0打开
下的源程序文件2.cpp。请完成以下两个函数。
(1)funl(int n)求出n的阶乘,必须使用递归调用。
(2)fun2(int n)求出n的阶乘,不能使用递归调用。如果n小于1则返回0。
注意:不能修改函数的其他部分。
试题程序:
#include<iostream.h>
//必须使用递归
int funl(int n)
{
}
//不能使用递归
int fun2(int n)
{
}
void main()
{
int i;
cout<<"请输入一个整数:"<<endl;
cin>>i;
cout<<"输入数字的阶乘是:"<<funl(i)<<endl;
cout<<"输入数字的阶乘是:"<<fun2(i)<<endl;
return;
}
问答题使用VC6打开下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。(1)完成类TestClass1的成员函数seta定义,定义seta对象x为int类型,请在注释//********1********后添加适当的语句。(2)完成类TestClass1(共有)和类TestClass2(私有)派生类TestClass3的定义,请在注释//********2********后添加适当的语句。(3)定义类TestClass3中的私有成员c为int,请在注释//********3********后添加适当的语句。(4)完成setc中对基类的变量a的赋值,请在注释//********4********后添加适当的语句。注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>C1assTeStClass1{inta;public://********1********{returna=x;}voidshowa(){coutaendl;}};classTestClass2{intb;public:voidsetb(intx){b=x;}voidshowb(){coutbendl;}};//********2********{private://********3********public:voidsetc(intx,inty,intz){c=z;//********4********setb(y);}voidshowc(){coutcendl;}};voidmain(){TestClass3c;c.seta(5);c.showa();c.setc(5,7,4);c.showc();}
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数fun(int n)的功能是在n行n列的矩阵中,每行都有最大的数,本程序求这n个最大数中的最小一个,并作为参数返回。
注意:不能修改程序的其他部分,只能修改fun()函数。
#include
#define N 100
int a[N][N];
int fun(int n)
{
}
Void main()
{
int n;
cout>n;
for(int i=0;i>a[i][j];
}
cout<<"The min of max numbers
is"<
问答题使用VC6打开下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为:1121注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>classTestClass{//********error********//********error********constintj;public:TestClass(){//********error********staticinti=0;cout++iendl;coutjendl;}};voidmain(){TestClassobj1;TestClassobj2;obj2.j+=obj1.j;return;}
问答题请使用VC6或使用【答题】菜单打开
proj1下的工程proj1,其中有枚举DOGCOLOR、狗类Dog和主函数main的定义。程序中位于每个“// 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);
// ERROR *******found*******
strcpy (this -> color, color);
}
DOGCOLOR getColor() const {return color;}
// ERROR *******found*******
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 << "There is a" << getColorString() << "dog named" << name << "." << endl;
}
};
int main() {
// ERROR *******found*******
Dog dog1("Hoho", WHITE), dog2("Haha", BLACK); dog3("Hihi", OTHER);
dog1.show();
dog2.show();
dog3.show();
return 0;
}
问答题使用VC6打开
下的源程序文件modi3.cpp,其中定义了用于表示学生学号的类CStudentID,但类CStudentID的定义并不完整。
运行结果为:
学生的学号为:200805
学生名为:李伟
删除学生学号为:200805
请按要求完成下列操作,将类CStudentID的定义补充完成:
(1)定义class CStudentID类的私有数据成员IDvalue表示学生的学号,为long型的数据。请在注释//********1********之后添加适当的语句。
(2)完成默认构造函数CStudentID的定义,使CStudentID对象的默认值为:id=0,并把学生的学号赋给IDvalue,并输出“赋给学生的学号:”及学号。请在注释//********2********之后添加适当的语句。
(3)完成默认析构函数CStudentID的定义,使CStudentID析构时输出“删除学号:”及学号。请在注释//********3********之后添加适当的语句。
(4)完成默认构造函数CStudentInfo的定义。对应两个默认参数:要求定义char stName[],其默认值为“no name”,定义long stID,其默认值设为0,并使它们赋值给相应的类数据成员。请在注释//********4********之后添加适当的语句。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
#include<iostream.h>
#include<string.h>
class CStudentID
{
//********1********定义私有数据成员
public:
//********2********定义默认构造函数
{
IDvalue=id;
cout
"学生的学号为: "
IDvalue
endl;
}
//********3********定义析构函数
{
cout
"删除学生学号为: "
IDvalue
endl;
}
};
class CStudentInfo
{
private:
CStudentID id;
char name[20];
public:
//********4********定义默认构造函数完成数据成员初始化
{
cout
"学生名为: "
stName
endl;
strcpy(name, stName);
}
};
void main()
{
CStudentInfo st ("李伟", 200805);
}
问答题请使用VC6或使用[答题]菜单打开
proj3下的工程proj3,其中声明的DataList类,是一个用于表示数据表的类。DataList的重载运算符函数operator+,其功能是求当前数据表与另一个相同长度的数据表之和;即它返回一个数据表,其每个元素等于相应两个数据表对应元素之和。请编写这个operator+函数。程序的正确输出应该是:
两个数据表:
1, 2, 3, 4, 5, 6
3, 4, 5, 6, 7, 8
两个数据表之和:
4, 6, 8, 10, 12, 14
要求:
补充编制的内容写在“//********333********”与“//********666********”之间,不得修改程序的其他部分。
注意:程序最后将结果输出到文件out. dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。
//DataList. h
#include<iostream>
using namespaee std;
class DataList {//数据表类
int len;
double*d;
public:
DataList(int len, double data[]=NULL);
DataList(DataList
int length()const {return len;}
double getElement(int i)const {return d[i];}
DataList operator+(const DataList//两个数据表求和
void show()const;//显示数据表
};
void writeToFile(char*, const DataList
//main. cpp
#include"DataList. h"
DataList::DataList(int len, double data[]): len(len) {
d=new double[len];
for(int i=0; i<len; i++)
d[i]=(data==NULL?0.0: data[i]);
}
DataList::DataList(DataList
for(int i=0; i<len; i++)
d[i]=data. d[i];
}
DataList DataList::operator+(const DataList
//********333********
//********666********
return DataList(list. length(), dd);
}
void DataList::show()const {//显示数据表
for(int i=0; i<len-1; i++)
cout<<d[i]<<",";
cout<<d[len-1]<<endl;
}
int main() {
double s1[]={1, 2, 3, 4, 5, 6};
double s2[]={3, 4, 5, 6, 7, 8};
DataList list1(6, s1), list2(6, s2);//定义两个数据表对象
cout<<”两个数据表:”<<endl;
list1. show();
list2. show();
cout<<endl<<"两个数据表之和:"<<endl;
list1+list2). show();
writeToFile(" ", listl+list2);
return 0;
}
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,使它能得出正确的结果。 本程序要求屏幕输出:n=99 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>//********error********class TestClass(){public: //********error******** void ~TestClass(){}; TestClass(int n) { cout<<'n'<<'='<<n<<endl: }; //********error}void main(){ TestClass test(99); return;}
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。(1)完成构造函数的定义,请在注释//********1********后添加适当的语句。(2)定义类的友元函数fun(),请在注释//********2********后添加适当的语句。(3)定义类的友元函数main(),请在注释//********3********后添加适当的语句。(4)补充语句,释放内存。请在注释//********4********后添加适当的语句。注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>class TestClass{public://********1********{data=d;next=NULL;}void SetNext(TestClass* p){next=p;}private:int data;TestClass* next;//********2********//********3********};TestClass* fun(TestClass* h){TestClasS *t,*s,*u,*v;s=h->next;h->next=NULL;while(s!=NULL){for(t=s,v=h;v!=NULL&&v->data<t->data;u=v,v=v->next);s=s->next;if(v==h)h=t;elseu->next=v;t->next=v;}return h;}void main(){TestClass* h=NULL;TestClass* q=NULL;do{int data;cout<<"please input a number,and end with0"<<endl;cin>>data;if(data==0)break;TestClass* p=newTestClass(data);if(h==NULL){h=q=p;}else{q->SetNext(p);q=p;}}while(1);h=fun(h);for(;h!=NULL;){q=h->next;cout<<h->data<<" "<<endl;delete h;//********4********}return;}
问答题请使用VC6或使用【答题】菜单打开考生目录proj3下的工程文件proj3,该文件中定义了用于表示日期的类Date、表示人员的类Person和表示职员的类Staff;程序应当显示: 张小丽123456789012345 但程序中有缺失部分,请按以下提示把缺失部分补充完整: (1)在“//**1** ****found****”的下方是析构函数定义中的语句,它释放两个指针成员所指向的动态空间。 (2)在“//**2** ****found****”的下方是rename函数中的一个语句,它使指针name指向申请到的足够容纳字符串new_name的空间。 (3)在“//**3** ****found****”的下方是构造函数定义的一个组成部分,其作用是利用参数表中前几个参数对基类Person进行初始化。 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“****found****”。填写的内容必须在一行中完成,否则评分将产生错误。//proj3.cpp#include<iostream>using namespace std;ClaSS Person{ char*idcardno;//用动态空间存储的身份证号 char*name; //用动态空间存储的姓名 bool ismale; //性别:true为男,false为女public: Person(const char*pid,const char*pname,bool pmale); 一Person(){//**1** **********found********** ____________; } const char*getIDCardNO()const{return idcardno;) const char*getName()const{return name;) void rename(const char*new name); bool isMale()const(return ismale;)},class Staff:public Person{ char*department; double salary;public: Staff(const char*id card no,const char*P_name,bool is_male,const char*dept,double sal); —Staff(){delete[]department;) const char*getDepartment()const{return department;) void setDepartment(const char*d); double getSalary()const{return salary;) void setSalary(double S){salary=S;} }, Person::Person fconst char*id card no,const char*P_name,bool_is_ male):ismale(iS male) { idcardno=new char[strlen(id card no)+1]; strcpy(idcardno,id card no); name=new char[strlen(p name)+1]; strcpy(name,P name); } void Person::rename ( const char*new name){ delete[]name;//**2** **********found********** _______; strcpy(name,new name);}Staff::Staff ( const char*id cardno,const char*P name,bool ismale,//**3** ********** found**********const char*dept,double sal):________{department=new char[strlen(dept)+1];strcpy(department,dept);salary=sal;}void Staff:: setDepartment (constchar*dept){delete[]department; department=new char[strlen(dept)+1];strcpy(department,dept);}int main(){ Staff Zhangsan(”123456789012345”,"张三",false,”人事部”,1234.56);Zhangsan.rename(”张小丽”);cout<<Zhangsan.getName()<<Zhang。san.getIDCardNO()<<endl; return 0;}
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程中包含一个头文件number.h,其中包含了类Number、OctNumber、HexNumber和DecNumber的声明;包含程序文件number.cpp,其中包含了上述类的成员函数toString的定义;还包含程序文件proj2.cpp,它以各种数制格式显示输出十进制数11。请在程序中的横线处填写适当的代码并删除横线,以实现上述功能。此程序的正确输出结果应为:
013,11,OXB
注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。
//mumber.h
class Number{
protected:
int n;
static char buf[33];
public:
Number(int k) :n(k) {}
//********** found**********
______;
//纯虚函数toString的声明
};
class HexNumber: public Number{
//16进制数
public:
//********** found**********
______//构造函数,参数名为k
const char* toString()const;
};
class OctNumber: public Number{
//八进制数
public:
OctNumber(int k):Number(k) {}
const char* toString()const;
};
class DecNumber: public Number{
//十进制数
public:
DecNumber(int k):Number(k){}
const char* toString()const;
};
//mumber.cpp
#include "Number.h"
#include <iostream>
#include <iomanip>
#include <strstream>
using namespace std;
char Number::buf[33] ="";
const char * HexNumber:: toString
()const
{
strstream str(buf,33);
str << hex << uppercase << showbase << n <<ends;
return buf;
}
const char * OctNumber::toString
()const
{
strstream str(buf, 33);
str << oct << showbase << n << ends;
return buf;
}
const char * DecNumber:: toString
()const
{
strstream str(buf,33);
str << dec << n << ends;
return buf;
}
//proj2.cpp
#include "Number.h"
#include <iostream>
using namespace std;
void show(Number //按既定的数制显示输出参数对象number的值
}
int main ( )
{
show(OctNumber(11)); cout << ',';
show(DecNumber(11)); cout << ',';
//********** found**********
______; //以16进制格式输出十进制数11
cout << endl;
return 0;
}
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程pmjl,此工程中含有一个源程序文件pmj1.cpp。其中位于每个注释“//ERROR****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:Thevalueofmemberobjectsis8注意:只修改注释“//ERROR****found****”的下一行语句,不要改动程序中的其他内容。//proj1.cpp#include<iostream>usingnamespacestd;ClaSsHember{public:Hember(intx){val=x;}intGetData(){returnval;}private://ERROR********found********intval=0;};classHyClass{public://ERROR********found********HyClass(intX){data=x;}voidPrint()//ERROR********found********{cout<<"ThevalueOfmemberobjectis"<<data.val<<end1;}private:Hemberdata;};intmain(){HyClassobj(8);obj.Print();return0;}
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp,要求编写一个CMyShape类,含有求面积求周长等纯虚函数。然后编写一个CMyRectangle类和CMyCircle类继承CMyShape,并实现求面积、求周长的两个函数。在main()函数中测试得到下面的结果: 在CMyShape类构函数造内 在CMyCircle类构造函数内 在CMyShape类构造函数内 在CMyRectangle类构造函数内 myCircle:Area=314.159 Girth=62.8319 myRectangle:Area=900 Girth=120 具体要求如下: (1)定义求面积纯虚函数,请在注释//********1********之处添加适当的语句。 (2)定义求周长纯虚函数,请在注释//********2********之处添加适当的语句。 (3)请在注释//********3********和//********4********之处添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>#include<math.h>#define PI 3.1415926class CMyPoint{public: int x,y; CMyPoint(int tx,int ty):x(tx),y(ty){));class CMyShape{public: CMyShape(){cout<<"在CMyShape类构造函数内"<<endl;} //********1******** //********2********protected:};class CMyCircle:public CmyShape{public: CMyCircle(CMyPoint i,doublej):CMyShape(),arcCenter(i),radius(j){ cout<<"在CMyCircle类构造函数内"<<endl; } double GetArea() { return PI*radius*radius; } double GetGirth() { return 2*PI*radius; }private: CMyPoint arcCenter; double radius;};class CMyRectangle:publicCmyShape{public: CMyRectangle(CMyPointit,CMyPoint rb):leftTop(1t),rightB0ttom(rb),CMyShape(){ cout<<"在 cMyRectangle类构造函数内"<<endl; } Double GetArea() { Int W1dth=abS(rightBottom.x-leftTop.x); int height:abs(rightBottom.y-leftTop.y); Return width*height; } double GetGirth() { int width=abs(rightBottom.x-leftTop.x); int height=abs(rightBottom.y-leftTop.y); return 2*(width+height); }private: CMyPoint leftTop,rightBottom;};Void main(){ CMyShape *myShape=NULL; CMyCircle *myCirCle=newCMyCircle(CMyPoint(5,5),10); CMyRectangle *myRectangle=new CMyRectangle(CMyPoint(0,0),CMyPoint(30,30)); //********3******** cout<<"myCircle:"<<"Area="<<myShape->GetArea()<<"\t" <<"Girth="<<myShape->GetGirth()<<endl; //********4******** cout<<"myRectangle:"<<"Area="<<myShape->GetArea()<<"\t" <<"Girth="<<myShape->GetGirth()<<endl;}
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中包含了类Integers和主函数main的定义。一个Integers对象就是一个整数的集合,其中包含0个或多个可重复的整数。成员函数add的作用是将一个元素添加到集合中,成员函数remove的作用是从集合中删除指定的元素(如果集合中存在该元素),成员函数sort的作用是将集合中的整数按升序进行排序。请编写这个sort函数。此程序的正确输出结果应为: 5 28 2 4 5 3 2 75 27 66 31 5 28 2 4 5 3 2 75 27 66 31 6 5 28 2 4 5 3 2 75 27 66 31 6 19 5 28 4 5 3 2 75 27 66 31 6 19 5 28 4 5 3 2 75 27 66 31 6 19 4 2 3 4 4 5 5 6 19 27 28 31 66 75 要求: 补充编制的内容写在“//**********333**********”与“//**********666**********”之间。不得修改程序的其他部分。 注意:相关文件包括:main.cpp、Integers.h。 程序最后调用writeToFile函数,使用另一组不同的测试数据,将不同的运行结果输出到文件out.dat中。输出函数writeToFile已经编译为obi文件。//Integers.h#ifndef INTEGERS#define INTEGERS#include<iostream>using namespace std;const int MAXELEMENTS=100;//集合最多可拥有的元素个数class Integers{int e lem[MAXELEMENTS];//用于存放集合元素的数组 int counter;//用于记录集合中元素个数的计数器public: Integers():counter(0){)//创建一个空集合 Integers(int data[],int size);//利用数组提供的数据创建一个整数集合 void add(int element);//添加一个元素到集合中 void remove(int element);//删除集合中指定的元素 int getCount()const{return counter;}//返回集合中元素的个数 int getElement(int i)const{return elem[i];)//返回集合中指定的元素 void sort();//将集合中的整数按由小到大的次序进行排序 void show()const;//显示集合中的全部元素};void writeToFile(const char*path);#endif//main.cpp#include”Integers.h”#include<iomanip>Integers::Integers(int data[],int Size):counter(0){ for(int i=0;i<Size;i++)add(da-ta[i]);}void Integers::add(int element){ if(counter<MAXELEMENTS) elem[counter++]=element; } void Integers::remove(int element){ int j; for(j=counter一1;j>=0;j一一) if(elem[j]=element)break; for(int i=j;i<counter一1;i++) elem[i]=elem[i+1]; counter一一; } void Integers::sort(){//********333********//********666********}void Integers::show()const{ for(int i=0;i<get;Count();i++) cout<<setw(4)<<getElement(i); cout<<endl;}int main(){ int d[]={5,28,2,4,5,3,2,75,27,66,31); Integers S(d,11); S.show(); S.add(6); S.show(); S.add(19); S.show(); s.Eemove(2); s.show(); s.add(4); s.show(); s.sort;(); s.show(); writeTOFile(””); return 0;}
问答题请使用VC6或使用【答题】菜单打开考生文件夹prog2下的工程prog2。此工程中包含一个程序文件main.epp,其中有“部门”类Department和“职工”类Staff的定义,还有主函数main的定义。在主函数中定义了两个“职工”对象,他们属于同一部门。程序展示,当该部门改换办公室后,这两个人的办公室也同时得到改变。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为: 改换办公室前: 职工号:0789 姓 名:张三 部 门:人事处 办公室:521 职工号:0513 姓 名:李四 部 门:人事处 办公室:521 改换办公室后: 职工号:0789 姓 名:张三 部 门:人事处 办公室:311 职工号:0513 姓 名:李四 部 门:人事处 办公室:311 注意:只在横线处填写适当的代码,不要改动程序中的其他内容。#include<iostream>using namespace std;class Department{//“部门”类public: Department (const char * name,const char*office){ strcpy(this一>name,name);//**********found********** } const char*getName()const{re-turn name;) //返回部门名称//**********found********** const char*getOffice()const{_________} //返回办公室房号 void changeOfficeT0(const char*office){ //改换为指定房号的另一个办公室 strcpy(this一>office,office); }private: char name[20];//部门名称 char office[20];//部门所在办公室房号 }; class Staff{ //“职工”类 public: //**********found********* Staff(const char*my id,constchar*my_name,Department Staff Zhang(”0 7 8 9”,”张三”,dept),Li(”0513”,”李四”,dept); cout<<"改换办公室前:"<<end1; showStaff(Zhang); showStaff(Li); //人事处办公室由521搬到311//**********found********** cout<<”改换办公室后:”<<endl; showStaff(Zhang); showStaff(Li); return 0;}
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码。函数show()的功能是将1、2、3、4四个数字,组成互不相同且无重复数字的四位数,并将这些数输出到屏幕,输出的内容如下:1234 1243 1324 1342 1423 1432 2134 2143 2314 2341 2413 2431 3124 3142 3214 3241 3412 3421 4123 4132 4213 4231 4312 4321将函数show()%b充完整。注意:请勿改动主函数。#include<iostream.h>void show(){}int main(){show();return0;}
问答题使用VC6打开考生文件夹下的源程序文件2.cpp。阅读下列函数说明和代码,补充空出的代码。函数sum(intn)返回1,2,3,…,n的和。其中n大于0。
程序要求使用递归实现上述功能。
注意:不能修改程序的其他部分,只能补充sum函数。
试题程序:
#include
#include
intsum(intn)
{
}
voidmain()
{
cout<<"1+2+3+…+100="< endl;
return;
}
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,使它能得出正确的结果。
本程序要求屏幕输出:
n=99
注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在∥********error********的下面。
#include
∥********error********
class TestClasS()
{
public:
∥********error********
void~TestClass(){);
TestClass(int n)
{
cout<<’n’<<':’<
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,实现函数sort(intA[],int n),用选择排序法把数组从大到小排序。 提示:选择排序法的思想是: (1)反复从还未排好的那部分线性表中选择出关键字最小的节点; (2)按照从线性表中选择出的顺序排列节点,重新组成线性表; (3)直到未排序的那部分为空,则重新形成的线性表是一个有序的线性表。 补充函数sort(int A[],int n),实现选择排序。 注意:请勿改动主函数。#include<ioStream.h>#define N 10void Sort(int A[N],int n){}int main(){ int A[N]={1,2,1 0,5,7,1 9,34,7 8,一3,8}; sort(A,1 0); for(int i=0;i<Si Zeof(A)/sizeof(int);i++) { cout<<A[i]<<‘ ’; } cout<<endl; return 0;}
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错误,请改正其中的错误,使程序正确运行。并且使程序输出的结果为:
OK
注意:错误的语句在∥********error********的下面,修改该语句即可。
#include
Class CBase
{
public:
CBase()
{
a=b=0;
}
prirate:
int a,b;
};
class CDerirel:public CBase
{
public:
CDerivel()
{
}
∥********error********
virtual void func();
};
class CDerive2:publiC CDerivel
{
public:
CDerive2()
{
a=0;
b=0;
}
void func()
{
∥********error********
coutfunC();
}