多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > php開源 > php教程 > C++ 運(yùn)算符重載

C++ 運(yùn)算符重載

來源:程序員人生   發(fā)布時(shí)間:2015-06-23 08:57:29 閱讀次數(shù):2410次
<span style="font-family: Arial, Helvetica, sans-serif;">#include <iostream></span>
using namespace std; class complex { public: // 帶缺省值的構(gòu)造函數(shù) complex (double real = 0, double image = 0) :_real(real) ,_image(image) { cout<<"complex (double real = 0, double image = 0)"<<endl; } // 析構(gòu)函數(shù) ~complex() { cout<<"~complex()"<<endl; } // 拷貝構(gòu)造函數(shù) complex (const complex& d) :_image(d._image) ,_real(d._real) { cout<<"complex (const complex& d)"<<endl; } // 賦值運(yùn)算符重載 complex& operator= (const complex& d) { cout<<"operator= (const complex& d)"<<endl; if (this != &d) { this->_real = d._real; this->_image = d._image; } return *this; } // 取地址運(yùn)算符重載 complex* operator& () { cout<<"operator&()"<<endl; return this; } // const修飾的取地址運(yùn)算符重載 const complex* operator& () const { cout<<"operator&() const"<<endl; return this; } void display() { cout<<"real:"<<_real<<"--image:"<<_image<<endl<<endl; } // 請實(shí)現(xiàn)下面的運(yùn)算符重載! complex& operator++() //前置++ //返回當(dāng)前對象本身 { cout<<"operator++()"<<endl; _real++; _image++; return *this; //可以立即體現(xiàn)出前置++的值 } complex operator++(int)//后置++ { cout<<"operator++(int)"<<endl; complex c = *this; this->_real++; this->_image++; return c; } complex& operator--() { cout<<"operator--()"<<endl; _real--; _image--; return *this; } complex operator--(int) //后置-- { cout<<"operator--()"<<endl; complex c = *this; this->_real--; this->_image--; return c; } complex operator+(const complex& c) { cout<<"operator+(const complex& c)"<<endl; return complex(_real+c._real,_image+c._image); } complex operator-(const complex& c) { cout<<"operator-(const complex& c)"<<endl; return complex(_real-c._real,_image-c._image); } complex& operator-=(const complex& c) { cout<<"operator-=(const complex& c)"<<endl; _real -= c._real; _image -= c._image; return *this; } complex& operator+=(const complex& c) { cout<<"operator+=(const complex& c)"<<endl; _real += c._real; _image += c._image; return *this; } complex operator*(const complex& c) { cout<<"operator*(const complex& c)"<<endl; return complex(_real*c._real-_image*c._image,c._image*_real+_image*c._real); } complex operator/(const complex& c) { cout<<"operator/(const complex& c)"<<endl; return complex((_real/c._real+_image*c._image)/(c,_real*c._real+c._image*c._image),(_image*c._real-_real*c._image)/(c,_real*c._real+c._image*c._image)); } private: double _real; double _image; };
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 欧美一级成人一区二区三区 | 最好免费高清视频在线看 | 亚洲精品国产一区二区图片欧美 | 久久精品第一页 | 琪琪在线 | 亚洲欧美日韩小说 | 老外一级毛片免费看 | 精品亚洲视频在线 | 欧美综合网站 | 国产私人尤物无码不卡 | 欧美中文字幕 | 亚洲欧美天堂综合久久 | 欧美日韩亚洲一区二区精品 | 一级做a级爰片性色毛片视频 | 欧美jizzhd精品欧美巨大 | 一本大道香蕉久在线不卡视频 | 国产亚洲一区在线 | 亚洲26uuuu最新地址 | 国产一区二区三区高清 | 欧美综合成人 | 一本大道加勒比久久 | 91久久偷偷做嫩草影院 | japanesexxx在线播放 | 女bbbbxxxx毛片视频0 | 国产精品嫩草影院视频 | 中文字幕国产视频 | 五月婷婷欧美 | 国产视频 每日更新 | 亚洲伊人成综合网 | 久草在线视频福利资源站 | 羞羞动漫视频在线观看 | 永久免费在线观看视频 | 九色国产| 富二代网站啪啪精品 | 日本一区二区三区欧美在线观看 | 日本中文字幕网站 | 在线高清一级欧美精品 | 三级黄在线播放 | 欧美精品videos | 在线a人片免费观看不卡 | 五月婷婷在线视频 |