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

亦庄专业网站开发公司wordpress技术文章

亦庄专业网站开发公司,wordpress技术文章,上海网优化seo公司,安徽响应式网站建设哪家有目录 前言#xff1a; 头文件类与函数的定义Date.h 实现函数的Date.cpp 测试Test.cpp 运行结果#xff1a; 前言#xff1a; 我们在前面的两章初步学习认识了《类与对象》的概念#xff0c;接下来我们将实现一个日期类#xff0c;是我们的知识储备更加牢固。 头文件…目录 前言 头文件类与函数的定义Date.h 实现函数的Date.cpp 测试Test.cpp 运行结果 前言 我们在前面的两章初步学习认识了《类与对象》的概念接下来我们将实现一个日期类是我们的知识储备更加牢固。 头文件类与函数的定义Date.h #pragma once #define _CRT_SECURE_NO_WARNIGS 1 #includeiostream using namespace std;class Date { public:friend ostream operator(ostream out, const Date d);int GetMonthDay(int _year, int _month){int day[13] { 0,31,28,31,30,31,30,31,31,30,31,30,31 };if ((_year % 4 0) (_year % 100 ! 0) || (_year % 400 0)){day[2] 29;}return day[_month];}Date(int year 2000, int month 1, int day 1){if (month 12 || day GetMonthDay(year, month)){cout Setting error!!! endl;exit(-1);}_year year;_month month;_day 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);Date operator(int day);Date operator(int day);Date operator();Date operator(int);Date operator-(int day);Date operator-(int day);Date operator--();Date operator--(int);int operator-(const Date d); private:int _year;int _month;int _day; }; 实现函数的Date.cpp #includeData.h 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); } bool Date::operator(const Date d) {if (_year d._year){return true;}else if (_year d._year){return false;}if (_month d._month){return true;}else if (_month d._month){return false;}if (_day d._day){return true;}return 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); }Date Date::operator(int day) {_day day;while (_day GetMonthDay(_year, _month)){_day - GetMonthDay(_year, _month);_month;if (_month 13){_month 1;_year;}}return *this; }Date Date::operator(int day) {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-(int day) {_day - day;while (_day 0){_month--;if (_month 0){_month 12;_year--;}_day GetMonthDay(_year, _month);}return *this; }Date Date::operator-(int day) {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; }int Date::operator-(const Date d) {int flag 1;Date max *this;Date min d;if (max min){max d;min *this;flag -1;}int count 0;while (max ! min){min;count;}return flag * count; }ostream operator(ostream out, const Date d) {out d._year 年 d._month 月 d._day 号;return out; } 测试Test.cpp #includeData.h int main() {Date d1(2024, 3, 10);cout d1 endl;Date d2(2024, 6, 17);cout d2 endl;printf(相差天数);cout (d2 - d1) endl;return 0; } 运行结果
http://www.hkea.cn/news/14341454/

相关文章:

  • 筑巢网站建设网站建设中 模板素材
  • 齐鲁建设网站网站建设的几大要素
  • wordpress快递模板下载常州网站排名优化
  • 品牌建设方案和思路辽源seo
  • 郑州网站设计制作wordpress+登录页加密
  • 做网站软件排名网站说明页命名
  • 网站建设会遇到哪些问题石家庄网页定制开发
  • 制作网站的过程细节网站域名所有权 查询
  • 怎么给网站做网站地图教务系统登录入口
  • 南头专业外贸网站建设公司苏州网站制作专业
  • wordpress 外贸建站cms建站是什么
  • 哪些网站做面试题课外辅导东莞网站建设技术支持
  • 做网站建设的怎么寻找客户网站建设合同缴印花税
  • 如何做外卖网站app唐山网站建设培训
  • tp5被黑做的网站全变成首页专业SEO教程网站
  • 网站建设的小结宁波seo在线优化方案公司
  • ui做网站实例网站站欣赏
  • 网站建设硬件条件网站建设能赚钱吗
  • 有没有帮忙做推广的网站建设小说网站费用
  • dede网站源码广州注册公司需要什么资料
  • 动态视频网站开发网站数据分析平台
  • 网站快照前显示中文怎么做的济南建设信息网站
  • 湖南英文网站建设seo是什么意思电商
  • 网站开发是什么费用大连网站建设是什么
  • 自己有主机怎么做论坛网站c2c电子商务网站定制开发
  • 游戏网站建设的策划方案seo难不难学
  • 网站开发拥有权约定公司网站开发立项文档
  • 开封网站建设公司排名企业做网站的费用如何科目
  • 公司网站百度小程序开发什么是门户网站建设平台
  • 做网站费用怎么付大气的广告公司名称