欢迎来到天天文库
浏览记录
ID:53249599
大小:51.00 KB
页数:6页
时间:2020-04-02
《面向对象上机实验5(参考代码).doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验5-1编一个程序,用成员函数重载运算符“+”和“-”将两个二维数组相加和相减,要求第1个二维数组的值由构造函数设置,另一个二维数组的值由键盘输入。#includeusingnamespacestd;#includeconstintrow=2;constintcol=3;classarray{public:array();//构造函数array(inta,intb,intc,intd,inte,intf);voidget_array();//由键盘输入数组的值voiddisplay();//显示数组的
2、值arrayoperator+(array&X);//将两个数组相加arrayoperator-(array&X);//将两个数组相减private:intvar[row][col];};array::array(){for(inti=0;i3、1][1]=e;var[1][2]=f;}voidarray::get_array()//由键盘输入数组的值{cout<<"Pleaseinput2*3dimensiondata:"<>var[i][j];}voidarray::display()//显示数组的值{for(inti=0;i4、ray::operator+(array&X)//将两个数组相加{arraytemp;for(inti=0;i5、;}intmain(){arrayX(11,22,33,44,55,66);arrayY,Z;Y.get_array();cout<<"DisplayobjectX"<6、算符“+”和“-”将两个二维数组相加和相减。#include#include//usingnamespacestd;constintrow=2;constintcol=3;classarray{public:array();//构造函数array(inta,intb,intc,intd,inte,intf);voidget_array();//由键盘输入数组的值voiddisplay();//显示数组的值friendarrayoperator+(array&X,array&Y);//将两个数组相7、加friendarrayoperator-(array&X,array&Y);//将两个数组相减private:intvar[row][col];};array::array(){for(inti=0;i8、;}voidarray::get_array()//由键盘输入数组的值{cout<<"Pleaseinput2*3dimensiondata:"<
3、1][1]=e;var[1][2]=f;}voidarray::get_array()//由键盘输入数组的值{cout<<"Pleaseinput2*3dimensiondata:"<>var[i][j];}voidarray::display()//显示数组的值{for(inti=0;i4、ray::operator+(array&X)//将两个数组相加{arraytemp;for(inti=0;i5、;}intmain(){arrayX(11,22,33,44,55,66);arrayY,Z;Y.get_array();cout<<"DisplayobjectX"<6、算符“+”和“-”将两个二维数组相加和相减。#include#include//usingnamespacestd;constintrow=2;constintcol=3;classarray{public:array();//构造函数array(inta,intb,intc,intd,inte,intf);voidget_array();//由键盘输入数组的值voiddisplay();//显示数组的值friendarrayoperator+(array&X,array&Y);//将两个数组相7、加friendarrayoperator-(array&X,array&Y);//将两个数组相减private:intvar[row][col];};array::array(){for(inti=0;i8、;}voidarray::get_array()//由键盘输入数组的值{cout<<"Pleaseinput2*3dimensiondata:"<
4、ray::operator+(array&X)//将两个数组相加{arraytemp;for(inti=0;i5、;}intmain(){arrayX(11,22,33,44,55,66);arrayY,Z;Y.get_array();cout<<"DisplayobjectX"<6、算符“+”和“-”将两个二维数组相加和相减。#include#include//usingnamespacestd;constintrow=2;constintcol=3;classarray{public:array();//构造函数array(inta,intb,intc,intd,inte,intf);voidget_array();//由键盘输入数组的值voiddisplay();//显示数组的值friendarrayoperator+(array&X,array&Y);//将两个数组相7、加friendarrayoperator-(array&X,array&Y);//将两个数组相减private:intvar[row][col];};array::array(){for(inti=0;i8、;}voidarray::get_array()//由键盘输入数组的值{cout<<"Pleaseinput2*3dimensiondata:"<
5、;}intmain(){arrayX(11,22,33,44,55,66);arrayY,Z;Y.get_array();cout<<"DisplayobjectX"<6、算符“+”和“-”将两个二维数组相加和相减。#include#include//usingnamespacestd;constintrow=2;constintcol=3;classarray{public:array();//构造函数array(inta,intb,intc,intd,inte,intf);voidget_array();//由键盘输入数组的值voiddisplay();//显示数组的值friendarrayoperator+(array&X,array&Y);//将两个数组相7、加friendarrayoperator-(array&X,array&Y);//将两个数组相减private:intvar[row][col];};array::array(){for(inti=0;i8、;}voidarray::get_array()//由键盘输入数组的值{cout<<"Pleaseinput2*3dimensiondata:"<
6、算符“+”和“-”将两个二维数组相加和相减。#include#include//usingnamespacestd;constintrow=2;constintcol=3;classarray{public:array();//构造函数array(inta,intb,intc,intd,inte,intf);voidget_array();//由键盘输入数组的值voiddisplay();//显示数组的值friendarrayoperator+(array&X,array&Y);//将两个数组相
7、加friendarrayoperator-(array&X,array&Y);//将两个数组相减private:intvar[row][col];};array::array(){for(inti=0;i8、;}voidarray::get_array()//由键盘输入数组的值{cout<<"Pleaseinput2*3dimensiondata:"<
8、;}voidarray::get_array()//由键盘输入数组的值{cout<<"Pleaseinput2*3dimensiondata:"<
此文档下载收益归作者所有