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

无锡网站制作.建设集团领导班子名单

无锡网站制作.,建设集团领导班子名单,昆山网站开发的公司,wordpress不能登录界面在上篇博客中#xff0c;我们已经对于日期类有了较为全面的实现#xff0c;但是#xff0c;还有一个问题#xff0c;比如说#xff0c;我给一个const修饰的日期类的对象 这个对象是不能调用我们上篇博客写的函数的#xff0c;因为d1是const Date*类型的#xff…在上篇博客中我们已经对于日期类有了较为全面的实现但是还有一个问题比如说我给一个const修饰的日期类的对象 这个对象是不能调用我们上篇博客写的函数的因为d1是const Date*类型的而this指针是Date*类型d1传给this是一种权限的放大这是不行的所以我们要改造一下相关函数就是声明和定义都要加上const那么具体形式如下 不只是这一个函数像比较大小加减天数等凡是不改变this指针指向的内容的值的都要加const那么这个符号加const吗不用因为这不是成员函数没有this指针 关于日期类的所有代码我会放在这篇文章的最后下面我们来说最后两个类的默认成员函数就是取地址操作符重载和const修饰的取地址操作符重载 这个默认成员函数确实没什么实际的作用就算我不写这个函数直接取地址也不会有任何问题唯一的作用就是你可以选择不返回this而返回空或一个假地址 Date.h文件 #includeiostream #includeassert.h using namespace std; class Date { public:Date(int year 1, int month 1, int day 1);Date* operator();const Date* operator()const;void Print()const;int GetMonthDay(int year, int month);bool operator(const Date n);bool operator!(const Date n);bool operator(const Date n);bool operator(const Date n);bool operator(const Date n);bool operator(const Date n);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);int operator-(const Date d);friend ostream operator(ostream out, const Date d);friend istream operator(istream in, Date d);private:int _year;int _month;int _day; };ostream operator(ostream out, const Date d); istream operator(istream in, Date d);Date.cpp文件 #includeDate.h 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 _year 年 _month 月 _day 日;cout 日期非法 endl;} } Date* Date:: operator() {return this; }const Date* Date::operator()const {return this; }void Date::Print() const{cout _year 年 _month 月 _day 日 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 % 400) 0) || ((year % 4) 0 (year % 100) ! 0))) {return 29;}return monthArray[month]; }bool Date:: operator(const Date n) {return _year n._year _month n._month _day n._day; }bool Date::operator!(const Date n) {return !(*this n); }bool Date:: operator(const Date n) {if (_year n._year) {return true;}if (_year n._year _month n._month) {return true;}if (_year n._year _month n._month _day n._day) {return true;}return false; }bool Date::operator(const Date n) {return ((*this n) || (*this n)); }bool Date::operator(const Date n) {return !(*this n); }bool Date:: operator(const Date n) {//return *this n || *this n;return !(*this n); }Date Date:: operator(int day) {if (day 0) {return *this - (-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) {Date tmp(*this);tmp day;return tmp; }Date Date:: operator-(int day) {if (day 0) {return *this - (-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) {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) { // int flag -1; // Date min *this; // Date max d; // if (*this d) { // min d; // max *this; // flag 1; // } // int n 0; // while (min max) { // min; // n; // } // return n*flag; //} int Date::operator-(const Date d) {int flag 1;Date max *this;Date min d;if (*this d) {max d;min *this;flag -1;}int n 0;int y min._year;while (y ! max._year) {if (y % 4 0 y % 100 ! 0 || y % 400 0) {n 366;}else {n 365;}y;}int m1 1;int m2 1;while (m1 max._month) {n GetMonthDay(max._year, m1);m1;}while (m2 min._month) {n - GetMonthDay(min._year, m2);m2;}n n max._day - min._day;return 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._yeard._month d._day;return in; }
http://www.pierceye.com/news/339092/

相关文章:

  • 实验报告网站建设与网页制作oa系统是什么
  • 信息发布网站开发模板提高网站响应速度
  • 本科网站开发毕业设计贵阳平台网站建设
  • 安徽省建设厅网站打不开杭州建设网 执法人员名单
  • 外贸网站建站公司如何做滴滴网站平台
  • 淄博张店做网站的公司建筑设计公司资质等级
  • 一个网站的建设需要哪些流程图eclipse的开发网站开发
  • 网站链接跳转怎么做建立数据库连接时出错wordpress
  • 漳州网站建设选博大不错江苏省建设工程注册中心网站
  • 文件下载网站源码免费做网站空间
  • 怎样给公司做一个网站做推广新网域名管理平台
  • 新蔡县做网站收多少钱二级分销利润分配模式
  • 鞍山百度网站怎么制作python培训视频教程
  • 湛江网站建设与网页网站建设需要什么证件
  • 东莞建站公司案例全网天下案例wordpress入门教程知乎
  • 网站策划书包含的内容化工设计网站
  • 做网站推广电话网站建设制作免费推广
  • 如何发布网站响应式商城网站
  • 网站建设应用程序开发网站建设的意义以及重要性
  • 网站建设进度说明嘉兴公司制作网站的
  • 山东省建设注册管理网站手机免费网站制作
  • 台州网站制作套餐如何查询网站的主机
  • 毕业设计代做哪个网站好房产中介如何找客源
  • 怎么下载自己做的网站杭州互联网公司排名
  • 做曖視頻网站网站开发设计流程论文
  • 北京移动官网网站建设凡科做的网站好吗
  • 申请网站域名怎么做wordpress金融主题
  • 中国建设银行移动门户网站wordpress 生成html代码
  • dw网站建设框架大小设定广州分销商城开发
  • 网站一年的 运营费用一般企业网站建设合同