freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

運(yùn)算符的重載-資料下載頁

2025-08-05 20:39本頁面
  

【正文】 } bool Point::operator==(Point p) { if(x==() amp。amp。y==()) return 1。 else return 0。 } bool Point::operator!=(Point p) { if(x!=() ||y!=() return 1。 else return 0。 } void Point::operator+=(Point p) { x+=()。y+=()。 } void Point::operator=(Point p) { x=()。y=()。 } Point Point::operator+(Point p) { thisx+=。 thisy+=。 return *this。 } Point Point::operator(Point p) { thisx=。 thisy=。 return *this。 } void main() { Point p1(2,3),p2(3,4),p3(p2)。 cout1:。 ()。 (10,10)。 cout2:。 ()。 cout3:(p2= =p3)endl。 cout4:(p2!=p3)endl。 p3+=p1。 cout5:。 ()。 p3=p2。 cout6:。 ()。 p3=p1+p3。 //先將 p1+p3的結(jié)果放在 p1中 , 然后賦給 p3 cout7:。 ()。 p3=p1p2。 cout8:。 ()。 } I/O運(yùn)算符重載 ? C++的 I/O流庫的一個(gè)重要特性就是能夠支持新的數(shù)據(jù)類型的輸出和輸入 。 用戶可以通過對(duì)插入符 ( ) 和提取符 ( ) 進(jìn)行重載來支持新的數(shù)據(jù)類型 。 ? 下面通過一個(gè)例子講述重載插入符和提取符的方法 。 ? 例: 分析下列程序,并給出執(zhí)行結(jié)果。 include class Date { public: Date(int y,int m,int d) {Year=y。Month=m。Day=d。} friend ostreamamp。 operator(ostream amp。stream,Date amp。date)。 friend istreamamp。 operator(istream amp。stream,Date amp。date)。 private: int Year,Month,Day。 }。 ostreamamp。 operator(ostream amp。stream,Date amp。date) { stream//endl。 return stream。 } istreamamp。 operator(istream amp。stream,Date amp。date) { stream。 return stream。 } void main() { Date Cdate(2022,1,1)。 coutCurrent date:Cdateendl。 coutEnter new date:。 cinCdate。 coutNew date:Cdateendl。 } 輸出結(jié)果為: Current date:2022/1/1 Enter new date:2022 1 15 ↙ New date:2022/1/15
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1