日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > C++ 運算符重載

C++ 運算符重載

來源:程序員人生   發布時間:2015-06-23 08:57:29 閱讀次數:2416次
<span style="font-family: Arial, Helvetica, sans-serif;">#include <iostream></span>
using namespace std; class complex { public: // 帶缺省值的構造函數 complex (double real = 0, double image = 0) :_real(real) ,_image(image) { cout<<"complex (double real = 0, double image = 0)"<<endl; } // 析構函數 ~complex() { cout<<"~complex()"<<endl; } // 拷貝構造函數 complex (const complex& d) :_image(d._image) ,_real(d._real) { cout<<"complex (const complex& d)"<<endl; } // 賦值運算符重載 complex& operator= (const complex& d) { cout<<"operator= (const complex& d)"<<endl; if (this != &d) { this->_real = d._real; this->_image = d._image; } return *this; } // 取地址運算符重載 complex* operator& () { cout<<"operator&()"<<endl; return this; } // const修飾的取地址運算符重載 const complex* operator& () const { cout<<"operator&() const"<<endl; return this; } void display() { cout<<"real:"<<_real<<"--image:"<<_image<<endl<<endl; } // 請實現下面的運算符重載! complex& operator++() //前置++ //返回當前對象本身 { cout<<"operator++()"<<endl; _real++; _image++; return *this; //可以立即體現出前置++的值 } 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; };
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 日韩不卡一区二区三区 | 国产美女久久 | 成人妇女免费播放久久久 | 在线一区视频 | 在线观看视频一区 | 国产精品网站视频 | 欧美激情在线精品一区二区三区 | 一级黄色免费网站 | 国产一区二区三区成人 | 人人爽视频 | 亚洲三级av | 久久国产一区二区 | 欧美日韩999 | caoprom超碰 | 精品免费国产一区二区三区四区 | 欧美a级成人淫片免费看 | 在线地址一地址二免费看 | 日韩av电影免费观看 | 2017天天操| 无码日韩精品一区二区免费 | 在线看国产| 中文字幕不卡在线 | 日韩欧美一区二区在线 | 久久综合五月 | 一集黄色大片 | 亚洲精品二 | 日韩欧美区 | 国产一区二区三区免费观看 | 成人免费ⅴa | 一区二区三区国产在线 | 亚洲视频在线视频观看视频在线 | 亚洲国产精品久久 | 日本视频在线观看 | 日韩欧美影院 | 成人国产精品入麻豆 | 国产在线网 | 欧美激情专区 | 欧美成人一区二区三区片免费 | 国产精品久久久99 | 久久久久久国产免费视网址 | 91成人综合|