C++ 中重载和运算符重载加号实现矩阵相加实例代码
C++重载+运算符重载加号实现矩阵相加
学习C++基础知识,这里实现简单的实例,记录下自己学习生活,很简单,大家一起看看吧!
实例代码:
#include#include usingnamespacestd; classComplex { private: inti,j,n,a[2][3]; public: Complex(); Complexoperator+(Complex&c); voiddisplay(); voidinput(); }t1; Complex::Complex() { for(inti=0;i<2;i++) for(intj=0;j<3;j++) a[i][j]=0; } voidComplex::input() { for(i=0;i<2;i++) for(j=0;j<3;j++) cin>>a[i][j]; } voidComplex::display() { n=1; for(i=0;i<2;i++) for(j=0;j<3;j++) { n++; if(n%2==0) cout< 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短