《C++ Primer》14.3.2节练习(部分)
生活随笔
收集整理的這篇文章主要介紹了
《C++ Primer》14.3.2节练习(部分)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
練習14.18:
String類的關系運算符就是比較兩個字符串字典序的先后。
另外2個類有時間再寫!!!
練習14.19:
class Date {friend bool operator<(const Date &d1,const Date &d2);friend bool operator<=(const Date &d1,const Date &d2);friend bool operator>(const Date &d1,const Date &d2);friend bool operator>=(const Date &d1,const Date &d2); };bool operator<(const Date &d1,const Date &d2) {return (d1.year < d2.year) || (d1.year==d2.year && d1.month < d2.month) || (d1.year==d2.year && d1.month==d2.month && d1.day < d2.day); } bool operator<=(const Date &d1,const Date &d2) {return (d1 < d2) || (d1==d2); }bool operator>(const Date &d1,const Date &d2) {return !(d1 <= d2); }bool operator>=(const Date &d1,const Date &d2) {return (d1 > d2) || (d1==d2); }總結
以上是生活随笔為你收集整理的《C++ Primer》14.3.2节练习(部分)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 比亚迪海洋网首款中型纯电SUV发布,海狮
- 下一篇: 曝iPhone 16标准版还是60Hz屏