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

百度免费网站如何建设wordpress 旅游足迹插件

百度免费网站如何建设,wordpress 旅游足迹插件,产品的网络推广要点,南京高端网站制作公司哪家好上一篇文章只实现了operator操作符重载#xff0c;由于运算符较多#xff0c;该篇文章单独实现剩余所有的运算符重载。继续以Date类为例#xff0c;实现运算符重载#xff1a; 1.Date.h #pragma once#include iostream #include assert.husing namespace … 上一篇文章只实现了operator操作符重载由于运算符较多该篇文章单独实现剩余所有的运算符重载。继续以Date类为例实现运算符重载 1.Date.h #pragma once#include iostream #include assert.husing namespace std;class Date { private:int _year;int _month;int _day; public:void Print();Date(int yaer, int month, int day);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);//单独的用一个函数把每个月多少天封装起来int GetMonthDays(int year, int month){assert(month 0 month 13);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)){return 29;}return MonthDay[month];}Date operator(int day);Date operator(int day);Date operator-(int day);Date operator-(int day);//d前置Date operator();//d后置Date operator(int);//前置--Date operator--();//后置--Date operator--(int);//两个日期相减d1-d2int operator-(const Date d); };Date.cpp #define _CRT_SECURE_NO_WARNINGS 1 #include stdio.h#include Date.hvoid Date::Print() {cout _year / _month / _day endl; }Date::Date(int year1, int month1, int day1) {_year year;_month month;_day day; } // 写好一个直接复用 bool Date::operator(const Date d) {if (_year d._year){return true;}else if (_year d._year){if (_month d._month)return true;else if ((_month d._month) (_day d._day))return true;elsereturn false;}elsereturn false; }bool Date::operator(const Date d) {if ((_year d._year) (_month d._month) (_day d._day))return true;elsereturn false; }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 || *this d); }bool Date::operator!(const Date d) {return !(*this d); }Date Date::operator(int day) {_day day;//先加//这里是while,因为如果是if的话如果一次加了很大的数据减一次不一定能减得完!!!while(_day GetMonthDays(_year, _month)){_day - GetMonthDays(_year, _month);_month;if (_month 13){_year;_month 1;}}return *this; }Date Date::operator(int day) {Date tmp*this;tmp day;return tmp; }Date Date::operator-(int day) {_day - day;while (_day 0){--_month;if (_month 0){--_year;_month 12;}_day GetMonthDays(_year, _month);}return *this; }Date Date::operator-(int day) {Date tmp *this;tmp - day;return tmp; }Date Date::operator() {return *this 1; }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) {int flag 1;Date max *this;Date min d;if (*this d){//赋值为-1的原因因为这个函数是有顺序的d1-d2如果遇到d1d2也就是小减大最终返回的结果是个负数所以说这里要变成-1。flag -1;max d;min *this;}//定义一个变量int n 0;// 用循环算两个日期中间的差值while (min ! max){min;n;}return n * flag; } 3.Test.cpp #define _CRT_SECURE_NO_WARNINGS 1 #include stdio.h #include Date.hint main() {Date d1(2024, 2, 15);Date d2 d1 20;d1.Print();d2.Print();bool retd1 d2;if (ret){d1.Print();}d2 100;d2.Print();d2 - 100;d2.Print();Date d3 d2 - 10;d3.Print();Date d4(2024, 1, 29);Date d5(2024, 8, 1);cout d5 - d4 endl;d5;d5.Print();d5;d5.Print();--d5;d5.Print();d5--;d5.Print();return 0; }
http://www.dnsts.com.cn/news/210195.html

相关文章:

  • 怎么评价一个网站设计做的好坏网站建设过程中准备的工作
  • node 做的大型网站seo整站优化服务
  • 专业网站建设阿里云asp.net 网站安装
  • 上海专业网站制作设计公司哪家好WordPress时间倒序
  • 推荐西安优秀的响应式网站建设公司暴雪国服
  • js网站跳转代码小程序公司
  • 黄冈建设信息网站上海企业注销一窗通
  • 哪里的网站建设好重庆龙华网站建设公司
  • 个人或主题网站建设网站后台统计
  • 手机网站制作流程图手机网站建设费用价格
  • 电子商务网站建设属性天津武清做网站的公司
  • 网站建设不好网站开发一般会用到什么语言
  • 孝感市门户网站管理中心合网站建设
  • 网站建设和优化的步骤wordpress添加网址导航页面
  • 学习网站开发流程wordpress打开速度慢 插件
  • 同步wordpress站点阳江网站seo服务
  • 网站虚拟主机共享网站域名年费
  • 推广产品网站建设wordpress注册文件下载
  • 深圳网站建设认准乐云践新网站如何自动手机版
  • 武清区网站开发邢台网站建设服务商
  • 西安哪家公司做网站好主题网络图怎么设计
  • 教育门户网站模板规划网站站点需要遵循哪些原则
  • 建设一个房产网站赚钱吗wordpress抖音插件
  • 站长之家端口扫描wordpress网页加入音乐页面
  • 东道网站建设seo网站排名优化
  • 网站直播间 是怎么做的简单网页制作模板图片
  • 企业网站建设可以分为几个层次怎样做访问外国网站才能不卡
  • 网站做百度口碑西宁建设网站多少钱
  • 互联网网站怎么做营销型网站要多少钱
  • wordpress网站密码百度快照下载