欢迎来到天天文库
浏览记录
ID:50845026
大小:37.01 KB
页数:2页
时间:2020-03-15
《类运算符重载C学习代码.docx》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#define_CRT_SECURE_NO_WARNINGS#include#include#includeusingnamespacestd;classmycomplex{intx;inty;public:friendostream&operator<<(ostream&out,mycomplex&Complex);friendistream&operator>>(istream&in,mycomplex&Complex);friendvoidoperator+(mycomplex&a,mycomplex&
2、b);mycomplex(){}mycomplex(inta,intb){x=a;y=b;}voidshow(){cout<3、ut;}istream&operator>>(istream&in,mycomplex&Complex){in>>Complex.x>>Complex.y;returnin;}voidmain(){mycomplexA(1,2);mycomplexB(2,3);A+B;system("pause");}voidmain3(){mycomplexA;cin>>A;A++;cout<>A;cout<4、n1(){mycomplexA(1,2);mycomplexB(2,3);A.show();B.show();cout<
3、ut;}istream&operator>>(istream&in,mycomplex&Complex){in>>Complex.x>>Complex.y;returnin;}voidmain(){mycomplexA(1,2);mycomplexB(2,3);A+B;system("pause");}voidmain3(){mycomplexA;cin>>A;A++;cout<>A;cout<4、n1(){mycomplexA(1,2);mycomplexB(2,3);A.show();B.show();cout<
4、n1(){mycomplexA(1,2);mycomplexB(2,3);A.show();B.show();cout<
此文档下载收益归作者所有