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

高邮建设银行网站百度怎么直接访问网址

高邮建设银行网站,百度怎么直接访问网址,建设一个网站平台的费用吗,网站建设需要什么东西#x1f525;博客主页#xff1a;小王又困了 #x1f4da;系列专栏#xff1a;C #x1f31f;人之为学#xff0c;不日近则日退 ❤️感谢大家点赞#x1f44d;收藏⭐评论✍️ 目录 一、日期类的实现 #x1f4d2;1.1日期类功能 #x1f4d2;1.2拷贝日期 #… 博客主页小王又困了 系列专栏C 人之为学不日近则日退 ❤️感谢大家点赞收藏⭐评论✍️ 目录 一、日期类的实现 1.1日期类功能 1.2拷贝日期 1.3重载关系运算符 1.4重载、 1.5重载 -、- 1.6重载、-- 一、日期类的实现 通过前面的知识我们要实现一个日期类巩固前面学习的类和对象。这里我们也要使用多文件来完成我们的日期类。 1.1日期类功能 头文件中是我们要实现日期类功能的函数声明。这里我们要注意拷贝函数只能在函数声明时写缺省值防止我们在声明和定义是给的缺省值不一样。 #include iostream #include assert.h using namespace std;class Date { public:Date(int year 1, int month 1, int day 1);void Print();int GetMonthDay(int year, int month);bool operator(const Date y);bool operator!(const Date y);bool operator(const Date y);bool operator(const Date y);bool operator(const Date y);bool operator(const Date y);int operator-(const Date d);Date operator(int day);Date operator(int day);Date operator-(int day);Date operator-(int day);Date operator();Date operator(int);Date operator--();Date operator--(int); private:int _year;int _month;int _day; }; 1.2拷贝日期 有时输入的日期可能是非法的例如月份大于12日期大于31还有闰2月天数等。所以我们要对输入的日期进行判断因为每个月的天数不同所以要用到GetMonthDay函数。 Date::Date(int year, int month, int day) {_year year;_month month;_day day;if (_year 1 || _month 1 || _month12 || _day 1 || _day GetMonthDay(_year, _month)){//assert(false);Print();cout 日期非法 endl;} }int Date::GetMonthDay(int year, int month) {assert(year 1 month 1 month 12);int monthArray[13] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31 };if (month 2 ((year % 4 0 year % 100 ! 0) || (year % 400 0)))return 29;return monthArray[month]; } 小Tips我们先判断是否是二月在判断是否是闰年可以提高效率。  1.3重载关系运算符 关系运算符有、、、、、!我们在写实现这些功能的代码时会发现它们逻辑相同会复制粘贴但这样的代码看着十分冗余我们可以通过复用来实现让代码更简单。 重载 bool Date::operator(const Date y) {return _year y._year _month y._month _day y._day; }重载! bool Date::operator!(const Date y) {return !(*this y); } 重载 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 y) {return *this y || *this y; } 重载 bool Date::operator(const Date y) {return !(*this y); } 重载 bool Date::operator(const Date y) {return !(*this y); } 1.4重载、 我们想知道50天之后的日期就可以通过重载、来实现。在加天数的时候由于每个月的天数不一样所以进位就不同我们要得到每个月份的天数。 获得月份的天数 int Date::GetMonthDay(int year, int month) {assert(year 1 month 1 month 12);int monthArray[13] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31 };if (month 2 ((year % 4 0 year % 100 ! 0) || (year % 400 0)))return 29;return monthArray[month]; } 小Tips把month 2放在前面判断可以提高效率如果不是二月就不需要判断是否是闰年如果是二月在判断。 重载 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 13){_year;_month 1;}}return *this; } 重载 Date Date::operator(int day) {if(x 0){return *this - (-day);}Date tmp(*this);tmp._day _day x;while (tmp._day GetDay(tmp._year, tmp._month)){tmp._day tmp._day - GetDay(tmp._year, tmp._month);tmp._month;if (tmp._month 13){tmp._year;tmp._month 1;}}return tmp; }小Tips重载是原来的日期不会改变所以我们拷贝构造了一个和*this相同的对象我们对tmp对象修改不会改变*this。重载是在原来的日期上直接修改所以我们直接对*this指向的日期进行修改然后返回就可以。 为什么重载用引用返回 在重载中*this就是d1它的作用域是函数结束后才销毁由于传值返回会拷贝一份返回值所以为了减少返回时的拷贝所以使用引用返回。在重载中tmp出了operator函数就被销毁所以只能使用传值返回。 和之间的复用 复用 Date Date::operator(int day) {Date tmp(*this);tmp day;return tmp; } 1.5重载 -、- 有时我们想知道以前的日期日期-天数可以知道多少天以前的日期日期-日期可以知道两个日期直接隔了多少天。两个operator-函数构成了函数重载。 重载- Date operator-(int x) {//天数天数小于0复用if (x 0){return *this -x;}_day - x;while (_day 0){_month--;if (_month 0){_month 12;_year--;}_day GetDay(_year, _month);}return *this; }重载日期-天数 Date Date::operator-(int x) {Date tmp(*this);return tmp - x; }重载日期-日期 日期-日期计算的结果是两个日期之间的天数所以返回值是int要知道两个日期之间相隔的天数可以设置一个计数器让小日期一直加到大日期就可以知道两个日期之间相隔的天数。 int 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 (max ! min){--max;n;}return n * flag; }1.6重载、-- 重载前置 前置要返回之后的值 Date Date::operator() {*this 1;//复用return *this; }重载前置 后置要返回之前的值 Date Date::operator(int)//编译器会把有int的视为后置 {Date tmp(*this);*this 1;//复用return tmp; }小Tips这两个operator函数构成了函数重载那调用的时候怎么区分前置和后置呢后置重载的时候多增加一个int类型的参数使用后置时调用运算符重载函数时不用传递参数编译器自动传递。 重载前置 --  前置--要返回--之后的值 Date operator--() {*this - 1;//复用-return *this }重载后置 --  后置--要返回--之前的值 Date operator--(int) {Date tmp(*this);*this - 1;//复用了-return tmp; }结语  本次的内容到这里就结束啦。希望大家阅读完可以有所收获同时也感谢各位读者三连支持。文章有问题可以在评论区留言博主一定认真认真修改以后写出更好的文章。你们的支持就是博主最大的动力。
http://www.zqtcl.cn/news/303494/

相关文章:

  • 景德镇市城市建设规划网站wordpress用不了了
  • 网站及新媒体建设宣传片wordpress 无法编辑主题
  • 东莞设计网站重庆做腋臭骑士网站
  • 什么软件可以搜索关键词精准网站信息优化的方式
  • 购物网站排名前十名山东泰安建筑工程集团有限公司
  • 源码下载站用vs网站开发
  • 自己做网站seo彩票的网站怎么做
  • 如何在网站后台找到死链接网站内页权重查询
  • 专业做国际网站网站开发的编程软件
  • 如何运营垂直网站网页工具大全
  • 如何让自己做的网站可以播放歌曲做培训网站
  • 做网站的毕业设计网站没备案怎么做淘宝客
  • 百度申诉网站建设银行住房租赁代表品牌是什么
  • 网站初期推广方案虚拟服务器搭建wordpress
  • jeecms可以做网站卖吗山西网络推广专业
  • 2017 如何做网站优化育儿哪个网站做的好
  • 网站制作容易吗青岛网站建设公司报价
  • 淘宝建设网站的好处网站制作结构
  • 网站开发网站建设公司临沂网站建设找谁
  • 咋么做网站在电脑上潍坊免费模板建站
  • 苏州网站建设推广咨询平台做网站的公司图
  • 北京企业网站怎么建设免费给我推广
  • 网站制作价钱多少专业的咨询行业网站制作
  • 做百度网站每年的费用多少交换友情链接时需要注意的事项
  • 怎么在百度网站上做自己的网站百度开户渠道
  • php技术的网站建设实录方案做二手手机的网站有哪些
  • 做网站店铺装修的软件怎么做淘课网站
  • 百度一下官方网站wordpress连接代码
  • 什么网站详情页做的好仿唧唧帝笑话门户网站源码带多条采集规则 织梦搞笑图片视频模板
  • 平原网站建设费用少儿编程加盟店倒闭