请打开考生文件夹下的解决方案文件proj1,该工程中包含程序文件main.cpp,其中有Salary(“工资”)类和主函数main的定义。程序中位于每个“//ERROR ****found****”之后的一行语句行有错误,请加以改正。改正后程序的输出结果应为: 应发合计:3500应扣合计:67.5 实发工资:3432.5 注意:只修改每个“//ERROR ****found****”下的那一行,不要改动程序中的其他内容。#includeiostreamusing namespace std;class Salary{public: Salary(const char*id,double the base,double the bonus,double the tax)//ERROR ********found******** :the base(base),the bonus(bonus),the tax(tax) { Staff id=new char [ strlen(id)+1]; strcpy(staff id,id); }//ERROR ****found**** ~Salary(){delete*Staff id;} double getGrossPay()const{return base+bonus;)//返回应发项合计 double getNetPay()const{return getGrossPay() - tax;}//返回实发工资额private: char*staff id; //职工号 double base;//基本工资 double bonus; //奖金 double tax; //代扣个人所得税};int main(){ Salary pay(“888888”,3000.0,500.0,67.50); cout"应发合计:"pay.get-GrossPay()" "; cout"应扣合计:"pay.get—GrosSPay()-pay.getNetPay()" ";//ERROR ********found******** cout"实发工资:"pay::getNetPay()endl; return 0;}
请打开考生文件夹下的解决方案文件proj2,其中有矩阵基类MatrixBase、矩阵类Matrix和单位阵UnitMatrix的定义,还有main函数的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:1 2 3 4 52 3 4 5 63 4 5 6 71 0 0 0 0 00 1 0 0 0 00 0 1 0 0 00 0 0 1 0 00 0 0 0 1 00 0 0 0 0 1注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#includeusing namespace std;//矩阵基础类,一个抽象类class MatrixBase{int rows,cols;public:MatrixBase(int rows,int cols):rows(rows),cols(cols){)int getRows( )const{returnroows}//矩阵行数int getCols( )const{returncols;}//矩阵列数virtual double getElement(intr,int c)const=0;//取第i个元素的值void show( )const{//分行显示矩阵中所有元素for(int i=0;icoutfor(int j=0;J//**********found**********cout}});//矩阵类class Matrix:public MatrixBase{double*val;public://**********found**********Matrix(int rows,int cols,double m[ ]=NULL):_______{//**********found**********val=_______;for(int i=0;ival[i]=(m==NULL?0.0:m[i]);}~Matrix( ){delete[ ]val;)double getElement(int r,intc)const{return val[r*getCols( )+c];}};//单位阵(主对角线元素都是1,其余元素都是0的方阵)类class UnitMatrix:public MatrixBase{public:UnitMatrix(int rows):MatrixBase(rows,rows){}//单位阵行数列数相同double getElement(int r,int c)const{//**********found**********if(_______)return1.0;return0.0;}};int main( ){MatrixBase*m;double d[ ][5]={{1,2,3,4,5),{2,3,4,5,6},{3,4,5,6,7}};m=new Matrix(3,5,(double*)d);m->show( );delete m;coutm=new UnitMatrix(6);m->show( );delete m;return0;}
请打开考生文件夹下的解决方案文件proj3,此工程中包含一个源程序文件proj3.cpp,其中定义了用于表示平面坐标系中的点的类MyPoint和表示矩形的类MyRectangle;程序应当显示: (0,2)(2,2)(2,0)(0,0)4 但程序中有缺失部分,请按照以下提示,把缺失部分补充完整: (1)在“//**1** ****found****”的下方是构造函数的定义,它用参数提供的左上角和右下角的坐标对up_left和down_right进行初始化。 (2)在“//**2** ****found****”的下方是成员函数getDownLeft的定义中的一条语句。函数getDownLeft返回用MyPoint对象表示的矩形的左下角。 (3)在“//**3** ****found****”的下方是成员函数area的定义,它返回矩形的面积。 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“****found****”。 1 //proj3.cpp 2 #includeiostream 3 using namespace std; 4 class MyPoint{//表示平面坐标系中的点的类 5 double x; 6 double y; 7 public: 8 MyPoint(double x,double y){this-x=x;this-y=y;} 9 double getX()const{return x;} 10 double getY()const{return y;} 11 void show()const(cout'('x','y:')';} 12 }; 13 class MyRectangle{ //表示矩形的类 14 MyPoint up left; //矩形的左上角顶点 15 MyPoint down right; //矩形的右下角顶点 16 public: 17 MyRectangle(MyPoint upleft,MyPoint downright); 18 MyPoint getUpLeft()const{return up left;}//返回左上角坐标 19 MyPoint getDownRight()const {return down right;} //返回右下角坐标 20 MyPoint getUpRight()const; //返回右上角坐标 21 MyPoint getD0wnLeft()const; //返回左下角坐标 22 double area()const; //返回矩形的面积 23 }; 24 //**1** **********found********** 25 MyRectangle:: MyRectangle (____________): up left(p1),down_right(p2){} 26 MyPoint MyRectangle::getUpRight ()const 27 { 28 return MyPoint(down_right.getX(),up_left.getY()); 29 } 30 MyPoint MyRectangle::getDown-Left()const 31 { 32 //**2** **********found********** 33 return MyPoint(___________); 34 } 35 //**3** **********found********** 36 ___________area()const 37 { 38 return(getUpLeft().getX()-getDownRight().getX()) *(getDownRight().getY()-getU-pLeft().getY()); 39 } 40 int main() 41 { 42 MyRectangle r(MyPoint(0,2), MyPoint(2,0)); 43 r.getUpLeft().show(); 44 r.getUpRight().show(); 45 r.getDownRight().show(); 46 r.getDownLeft().show(); 47 coutr.area()endl; 48 return 0; 49 }
操作题使用 VC6 打开考生文件夹 proj1 下的工程 proj1, 其中有沙发 类 Sofa 和主函数 main 的定义
操作题使用 VC6 打开考生文件夹 proj1 下的工程 proj1, 其中定义了一个 CD 类
应用题使用 VC6 打开考生文件夹 proj3 下的工程 proj3, 其中声明了 MyString 类, 它是一个用于表示字符串的类
单选题数据库管理系统是位于用户与操作系统之间的一个数据管理软件,以下不属于它的基本功能的是( )。
单选题有如下程序:
#include
usingnamespacestd;
classTestClass
{public:
virtualvoidfunl()
{coutfun1();
p->fun2();
return0;}
该程序执行后的输出结果是( )。
单选题下列关系运算中,能使经运算后得到的新关系中属性个数多于原来关系中属性个数的是
____
。
单选题有如下函数模板定义: template<class T> T func(T x,T y){return x*x+y*y;} 在下列对func的调用中,错误的是( )。
单选题有如下程序: #include<iostream> using namespace std; class VAC{ public; int f() const{return 3;} int f() {return 5;} }; Int main(){ VAC v1; const VAC v2; cout<<v1.f()<<v2.f(); fetum 0; } 运行时的输出结果是( )。
单选题Windows环境下,由C++源程序文件编译而成的目标文件的扩展名是( )。