当前位置: 首页 > news >正文

风云办公ppt模板网站深圳游戏网站开发

风云办公ppt模板网站,深圳游戏网站开发,黄页电话号码,睢宁网站制作一路#xff0c;一路#xff0c;一路从泥泞到风景............................................................................................... 目录 前言 一、【什么是日期类】 二、【代码实现】 1.【Date.h】部分#xff1a; 2.【Date.cpp】部分#xff1a;… 一路一路一路从泥泞到风景............................................................................................... 目录 前言 一、【什么是日期类】 二、【代码实现】 1.【Date.h】部分 2.【Date.cpp】部分 3.【Test.cpp】部分 总结 前言 本篇是日期类的编写望多多指正。 一、【什么是日期类】 在学习完类和对象之后可以试着编写一个日期类进行练习使得该类能够加减天数计算两个日期之间相差的天数还可以比较两个类之间的大小。 二、【代码实现】 1.【Date.h】部分 #define _CRT_SECURE_NO_WARNINGS #include stdio.h #include iostream #include stdbool.h #include assert.h using namespace std; class Date { public:friend ostream operator(ostream out, const Date d);friend istream operator(istream in, Date d);int GetMonthDay(int year, int month);Date(int year 1, int month 1, int day 1);Date(const Date d);bool operator(const Date d);bool operator(const Date d);bool operator(const Date d);bool operator(const Date d);bool operator(const Date d);bool operator!(const Date d);Date operator(int day);Date operator(int day)const;Date operator-(int day)const;Date operator-(int day);Date operator();Date operator(int);Date operator--(int);Date operator--();int operator-(const Date d); private:int _year;int _month;int _day; }; 2.【Date.cpp】部分 #include Date.h int Date::GetMonthDay(int year, int month) {const static int MonthDay[13] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };if ((month2)(year % 4 0 year % 100 ! 0 ) || (year % 400 0)){return 29;}return MonthDay[month]; } Date::Date(int year, int month, int day) {_year year;_month month;_day day;if (year 1 || month 1 || month12 || day1 || dayGetMonthDay(year,month)){cout error date endl;exit(-1);} } Date::Date(const Date d) {_year d._year;_month d._month;_day d._day; } bool Date::operator(const Date d) {if (_year d._year){return true;}else if (_year d._year _month d._month){return true;}else if (_year d._year _month d._month _day d._day){return true;}else{return false;} } bool Date::operator(const Date d) {return (_year d._year) (_month d._month) (_day d._day); } bool Date::operator(const Date d) {return (*this d) || (*this d); } bool Date::operator(const Date d) {return !(*this d); } bool Date::operator(const Date d) {return !(*this d); } bool Date::operator!(const Date d) {return !(*this d); } Date Date::operator(int day) {if (day 0){return *this - (-day);}_day day;while(_day GetMonthDay(_year, _month)){_day - GetMonthDay(_year, _month);_month;if (_month 12){_year;_month 1;}}return *this; } Date Date::operator(int day)const {Date tmp(*this);tmp day;return tmp; } //Date Date::operator-(int day) //{ // Date tmp(*this); // tmp._day - day; // while (tmp._day 0) // { // tmp._month--; // if (tmp._month 1) // { // tmp._year--; // tmp._month 12; // } // tmp._day tmp.GetMonthDay(tmp._year, tmp._month); // } // return tmp; //} //Date Date::operator-(int day) //{ // *this *this - day; // return *this; //}Date Date::operator-(int day) {if (day 0){return *this (-day);}_day - day;while (_day 0){--_month;if (_month 0){--_year;_month 12;}_day GetMonthDay(_year, _month);}return *this; }Date Date::operator-(int day) const {Date tmp(*this);tmp - day;return tmp; } Date Date::operator() {*this 1;return *this; }Date Date::operator(int) {Date tmp(*this);*this 1;return tmp; }Date Date::operator--() {*this - 1;return *this; }Date Date::operator--(int) {Date tmp(*this);*this - 1;return tmp; } int Date::operator-(const Date d) {Date Max *this;Date Min d;int flag 1;if (*this d){Max d;Min *this;flag -1;}int n 0;while (Min ! Max){Min;n;}return flag * n;} ostream operator(ostream out, const Date d) {out d._year / d._month / d._day endl;return out; }istream operator(istream in, Date d) {in d._year d._month d._day;return in; } 3.【Test.cpp】部分 #define _CRT_SECURE_NO_WARNINGS #include Date.h int main() {Date d1(2023,7,1);Date d2(2023, 7, 28);cout d1 endl;cout d2 endl;cout (d2-d1) endl;cout (d2) endl;cout (d2) endl;cout d2 endl; cout (d1--) endl;cout (--d1) endl;Date sum d2 260;cout sum endl;cout (d2480) endl;return 0; } 总结 本片到这里就结束了感谢观看 .......................................................................................................你过得好吗会想起我吗                                                                                                           ————《你过得好吗》
http://www.pierceye.com/news/94599/

相关文章:

  • 如何查网站外链wordpress火车头采集免费版
  • 四川住房建设和城乡建设厅新网站wordpress 采集 api
  • 企业所得税怎么交南昌seo实用技巧
  • 深圳英文网站开发企业网站和展板建设
  • 国内网站设计制作网页游戏传奇盛世开服表
  • 网站图片放大特效怎么做网站建设的后期服务要包括什么软件
  • 网站降权投诉商标注册证书电子版怎么查询
  • 济南网站制作公司哪家好网站建设搞笑广告词
  • 建设主管部门门户网站摄影网站源码 免费下载
  • js 曲线 网站营销型网站方案书
  • 如何盗取网站软件开发的自学教程
  • 傻瓜建站家庭网络搭建网站
  • 扬中做网站的公司静态网页生成器
  • 襄阳做公司网站的软件公司wordpress网站好做排名吗
  • 电商网站功能介绍太原市做网站公司
  • 网站开发融资计划网站响应式和电脑手机
  • 专做水果的网站天门市规划建设局网站
  • 网站百度地图生成器建设一个网站可以做什么
  • 用阳寿做交易的网站建盏公司简介
  • 机械加工网站哪个好服装设计专业有前途吗
  • 深圳 企业 网站建设哪家好没有域名的网站需要备案吗
  • 深圳返利网站建设扁平化 手机网站首页
  • 郑州核酸点推vip服务网站优化标准
  • 建设银行河南分行网站邢台做网站哪里便宜
  • 网站收录原创文章wordpress新框架vue
  • 中工信融做网站怎么样凡科建站代理平台
  • 网站设计图能用ps做么dedecms 图片网站
  • 自己有服务器怎么做网站wordpress会员卡
  • 网站打不开 ...wordpress 评论表情插件
  • 网站开发框架 Wordpress网站整体设计流程