欢迎来到天天文库
浏览记录
ID:42340043
大小:46.00 KB
页数:7页
时间:2019-09-13
《C++习题答案-5》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第五章多态性5.7D5.8A5.9A5.10D5.11C5.12C5.13不正确。虚函数在派生类中重新定义时,其函数原型,包括函数类型,函数名,参数个数与参数类型的顺序,都必须与基类中的原型完全相同。5.14765.15ThisisC++book.第1个字符:T第16个字符:k第26个字符:数组下标超界!5.16m=1.5千米5.17#includeusingnamespacestd;#includeconstintrow=2;constintcol=3;classarray{public
2、:array();array(inta,intb,intc,intd,inte,intf);voidget_array();voiddisplay();arrayoperator+(array&x);arrayoperator-(array&x);private:intvar[row][col];};array::array(){for(inti=0;i3、ar[0][0]=a;var[0][1]=b;var[0][2]=c;var[1][0]=d;var[1][1]=e;var[1][2]=f;}voidarray::get_array(){cout<<”pleaseinput2*3dimensiondata:”<>var[i][j];}voidarray::display(){for(inti=0;i4、setw(5)<5、i][j]-x.var[i][j];returntemp;}intmain(){arrayx(11,22,33,4,5,6);arrayy,z;y.get_array();cout<<”Displayobjectx”<6、y();return0;}5.18#includeusingnamespacestd;#includeconstintrow=2;constintcol=3;classarray{public:array();array(inta,intb,intc,intd,inte,intf);voidget_array();voiddisplay();friendarrayoperator+(array&x,array&y);friendarrayoperator-(array&x,array&y)7、;private:intvar[row][col];};array::array(){for(inti=0;i8、ondata:”<>var[i][j];}voidarray::display(){for(inti=0;i
3、ar[0][0]=a;var[0][1]=b;var[0][2]=c;var[1][0]=d;var[1][1]=e;var[1][2]=f;}voidarray::get_array(){cout<<”pleaseinput2*3dimensiondata:”<>var[i][j];}voidarray::display(){for(inti=0;i4、setw(5)<5、i][j]-x.var[i][j];returntemp;}intmain(){arrayx(11,22,33,4,5,6);arrayy,z;y.get_array();cout<<”Displayobjectx”<6、y();return0;}5.18#includeusingnamespacestd;#includeconstintrow=2;constintcol=3;classarray{public:array();array(inta,intb,intc,intd,inte,intf);voidget_array();voiddisplay();friendarrayoperator+(array&x,array&y);friendarrayoperator-(array&x,array&y)7、;private:intvar[row][col];};array::array(){for(inti=0;i8、ondata:”<>var[i][j];}voidarray::display(){for(inti=0;i
4、setw(5)<5、i][j]-x.var[i][j];returntemp;}intmain(){arrayx(11,22,33,4,5,6);arrayy,z;y.get_array();cout<<”Displayobjectx”<6、y();return0;}5.18#includeusingnamespacestd;#includeconstintrow=2;constintcol=3;classarray{public:array();array(inta,intb,intc,intd,inte,intf);voidget_array();voiddisplay();friendarrayoperator+(array&x,array&y);friendarrayoperator-(array&x,array&y)7、;private:intvar[row][col];};array::array(){for(inti=0;i8、ondata:”<>var[i][j];}voidarray::display(){for(inti=0;i
5、i][j]-x.var[i][j];returntemp;}intmain(){arrayx(11,22,33,4,5,6);arrayy,z;y.get_array();cout<<”Displayobjectx”<6、y();return0;}5.18#includeusingnamespacestd;#includeconstintrow=2;constintcol=3;classarray{public:array();array(inta,intb,intc,intd,inte,intf);voidget_array();voiddisplay();friendarrayoperator+(array&x,array&y);friendarrayoperator-(array&x,array&y)7、;private:intvar[row][col];};array::array(){for(inti=0;i8、ondata:”<>var[i][j];}voidarray::display(){for(inti=0;i
6、y();return0;}5.18#includeusingnamespacestd;#includeconstintrow=2;constintcol=3;classarray{public:array();array(inta,intb,intc,intd,inte,intf);voidget_array();voiddisplay();friendarrayoperator+(array&x,array&y);friendarrayoperator-(array&x,array&y)
7、;private:intvar[row][col];};array::array(){for(inti=0;i8、ondata:”<>var[i][j];}voidarray::display(){for(inti=0;i
8、ondata:”<>var[i][j];}voidarray::display(){for(inti=0;i
此文档下载收益归作者所有