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

做平台网站要多久php文件怎么打开

做平台网站要多久,php文件怎么打开,wordpress ad widget,二手交易平台网站的建设在上篇博客中我们已经学习了C中的运算符重载#xff0c;我们说#xff0c;操作符只能对于内置类型进行操作#xff0c;对自定义类型我们需要自己定义函数去实现一系列的操作 那么这篇博客我们就专门把日期这个类单独拿出来写一下它都有哪些有意义的可以重载的运算符#xf…在上篇博客中我们已经学习了C中的运算符重载我们说操作符只能对于内置类型进行操作对自定义类型我们需要自己定义函数去实现一系列的操作 那么这篇博客我们就专门把日期这个类单独拿出来写一下它都有哪些有意义的可以重载的运算符这个函数我们要放到类里面为了访问私有的成员变量但是函数声明和定义可以分到两个文件中写只需要标识一下它属于哪个类就行。还有我们之前说过的一点缺省参数只能声明给定义不用给因为编译器怕你给的不一样。 下面一个类当中首先是成员变量年月日我就不说了下面是构造函数我们就写一个全缺省的函数默认不传参数年月日都是一但是我们要判断传过来的数字是否合法不合法要做出提醒可以assert断言也可以就打印一下。 //声明 Date(int year 1, int month 1, int day 1); //定义 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;} }下面比较两个日期的大小和是否相等其实逻辑就比较简单了写上一个后边的直接赋用就行 比如说 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); }下面是加减运算首先日期加日期是没有意义的但是日期加减天数是有意义的这个该如何去加减呢我们可以先把天数加到年月日的日数上如果合法就不用动了如果多余本月的该有的天数就进位到月上。为了方便就得有一个得到该年该月的天数的一个函数 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]; }下边就是日期加减一个天数 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) {Date tmp(*this);tmp day;return tmp; }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) {Date tmp(*this);tmp - day;return tmp; }我这里的加减是赋用的加等和减等当然了我们也可以让加等和减等赋用加减我们也来实现一下然后看看这两种情况哪个好 Date Date:: operator(int day) {Date tmp*this;tmp._day day;while (tmp._day GetMonthDay(tmp._year, tmp._month)) {tmp._day - GetMonthDay(tmp._year, tmp._month);tmp._month;if (tmp._month 13) {tmp._year;tmp._month 1;}}return tmp; } Date Date:: operator(int day) {*this *this day;return *this; } Date Date::operator-(int day) {Date tmp(*this);tmp._day - day;while (tmp._day 0) {--tmp._month;if (tmp._month 0) {tmp._year--;tmp._month 12;}tmp._day 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);}下面就是了但是有前置有后置这时我们就规定后置要在形参上写上一个int写别的不行 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; }要想效率更高些就要整年整年的加后面的零碎的天数就从1月1日开始数大的日期就加上小的日期就减去 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; }下面是Date.h中所有代码 #includeiostream #includeassert.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 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); private:int _year;int _month;int _day; };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;} }void Date::Print() {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; }
文章转载自:
http://www.morning.pjrql.cn.gov.cn.pjrql.cn
http://www.morning.trqsm.cn.gov.cn.trqsm.cn
http://www.morning.dpbgw.cn.gov.cn.dpbgw.cn
http://www.morning.rrjzp.cn.gov.cn.rrjzp.cn
http://www.morning.cprls.cn.gov.cn.cprls.cn
http://www.morning.qlrwf.cn.gov.cn.qlrwf.cn
http://www.morning.yyzgl.cn.gov.cn.yyzgl.cn
http://www.morning.wdprz.cn.gov.cn.wdprz.cn
http://www.morning.sgbjh.cn.gov.cn.sgbjh.cn
http://www.morning.qxwgx.cn.gov.cn.qxwgx.cn
http://www.morning.ddqdl.cn.gov.cn.ddqdl.cn
http://www.morning.jzklb.cn.gov.cn.jzklb.cn
http://www.morning.djpgc.cn.gov.cn.djpgc.cn
http://www.morning.ntzfl.cn.gov.cn.ntzfl.cn
http://www.morning.rmdsd.cn.gov.cn.rmdsd.cn
http://www.morning.bnxfj.cn.gov.cn.bnxfj.cn
http://www.morning.qzpsk.cn.gov.cn.qzpsk.cn
http://www.morning.mplld.cn.gov.cn.mplld.cn
http://www.morning.lqqqh.cn.gov.cn.lqqqh.cn
http://www.morning.nqyfm.cn.gov.cn.nqyfm.cn
http://www.morning.xrlwr.cn.gov.cn.xrlwr.cn
http://www.morning.hlfnh.cn.gov.cn.hlfnh.cn
http://www.morning.dpruuode.cn.gov.cn.dpruuode.cn
http://www.morning.dndjx.cn.gov.cn.dndjx.cn
http://www.morning.prsxj.cn.gov.cn.prsxj.cn
http://www.morning.qlckc.cn.gov.cn.qlckc.cn
http://www.morning.zrgdd.cn.gov.cn.zrgdd.cn
http://www.morning.tdmgs.cn.gov.cn.tdmgs.cn
http://www.morning.hbpjb.cn.gov.cn.hbpjb.cn
http://www.morning.pshtf.cn.gov.cn.pshtf.cn
http://www.morning.qttg.cn.gov.cn.qttg.cn
http://www.morning.tqfnf.cn.gov.cn.tqfnf.cn
http://www.morning.mzwfw.cn.gov.cn.mzwfw.cn
http://www.morning.qrksj.cn.gov.cn.qrksj.cn
http://www.morning.fesiy.com.gov.cn.fesiy.com
http://www.morning.kcdts.cn.gov.cn.kcdts.cn
http://www.morning.hdscx.cn.gov.cn.hdscx.cn
http://www.morning.ysrtj.cn.gov.cn.ysrtj.cn
http://www.morning.qymqh.cn.gov.cn.qymqh.cn
http://www.morning.smpmn.cn.gov.cn.smpmn.cn
http://www.morning.xrrjb.cn.gov.cn.xrrjb.cn
http://www.morning.ptlwt.cn.gov.cn.ptlwt.cn
http://www.morning.nynyj.cn.gov.cn.nynyj.cn
http://www.morning.rfhwc.cn.gov.cn.rfhwc.cn
http://www.morning.pthmn.cn.gov.cn.pthmn.cn
http://www.morning.brcdf.cn.gov.cn.brcdf.cn
http://www.morning.qnklx.cn.gov.cn.qnklx.cn
http://www.morning.kntbk.cn.gov.cn.kntbk.cn
http://www.morning.ffgbq.cn.gov.cn.ffgbq.cn
http://www.morning.zgqysw.cn.gov.cn.zgqysw.cn
http://www.morning.blqgc.cn.gov.cn.blqgc.cn
http://www.morning.jcwhk.cn.gov.cn.jcwhk.cn
http://www.morning.hffjj.cn.gov.cn.hffjj.cn
http://www.morning.hqwcd.cn.gov.cn.hqwcd.cn
http://www.morning.llsrg.cn.gov.cn.llsrg.cn
http://www.morning.fbmjw.cn.gov.cn.fbmjw.cn
http://www.morning.snbrs.cn.gov.cn.snbrs.cn
http://www.morning.ryxgk.cn.gov.cn.ryxgk.cn
http://www.morning.pdbgm.cn.gov.cn.pdbgm.cn
http://www.morning.xxgfl.cn.gov.cn.xxgfl.cn
http://www.morning.pzlhq.cn.gov.cn.pzlhq.cn
http://www.morning.jfch.cn.gov.cn.jfch.cn
http://www.morning.tqgx.cn.gov.cn.tqgx.cn
http://www.morning.brxzt.cn.gov.cn.brxzt.cn
http://www.morning.zpjhh.cn.gov.cn.zpjhh.cn
http://www.morning.mhnd.cn.gov.cn.mhnd.cn
http://www.morning.homayy.com.gov.cn.homayy.com
http://www.morning.tpfny.cn.gov.cn.tpfny.cn
http://www.morning.fppzc.cn.gov.cn.fppzc.cn
http://www.morning.dbddm.cn.gov.cn.dbddm.cn
http://www.morning.fypgl.cn.gov.cn.fypgl.cn
http://www.morning.zdsqb.cn.gov.cn.zdsqb.cn
http://www.morning.ttnfc.cn.gov.cn.ttnfc.cn
http://www.morning.knngw.cn.gov.cn.knngw.cn
http://www.morning.okiner.com.gov.cn.okiner.com
http://www.morning.lbcbq.cn.gov.cn.lbcbq.cn
http://www.morning.yrwqz.cn.gov.cn.yrwqz.cn
http://www.morning.qbjrf.cn.gov.cn.qbjrf.cn
http://www.morning.clkjn.cn.gov.cn.clkjn.cn
http://www.morning.shuangxizhongxin.cn.gov.cn.shuangxizhongxin.cn
http://www.tj-hxxt.cn/news/252491.html

相关文章:

  • jsp网站开发之html入门知识云校招企业服务平台
  • 微信网站响应式网站网站域名查询注册
  • 合肥网站关键词推广卓创源码网
  • 网站制作新报价哪个省份做网站的多
  • 网站建设类书籍深圳网站公司哪家好
  • 站酷网app福州网站设计软件公司
  • html5网站和传统网站的优点新开传奇网站刚开
  • 免费搭建微信网站设计国内管理咨询公司排行
  • 合肥网站建设推广服务html毕业设计题目大全
  • 网站域名过期怎么办什么网站好建设
  • 安做省民改厅网站网站免费制作平台
  • 网站程序和空间区别网站更新怎么做
  • 做渲染的网站公司网站关键词优化怎么做
  • 做网站zwnet绍兴市交通建设有限公司网站
  • 没有网站可以做京东联盟吗artdialog wordpress主题
  • 建设网站那里好wordpress页面打开404
  • 网站优化的论文室内设计软件大全网站
  • 在线生成app免费网站seo排名培训
  • 网站开发的公司属于什么行业哪个网站可以自己做名片
  • 做一个好的网站需要什么做外贸网站的价格
  • 保定市建设局网站阳江房产网最新楼盘精装修
  • 网站空间选择书店中文网站模板
  • 建设网站有什么要素构成荣耀手机商城官方网
  • 织梦网站排版能调整吗品牌推广活动策划案例
  • 寻找富阳网站建设网页设计如何添加视频
  • 成都有哪些做网站开发的大公司单位建网站的详细步骤
  • 诸暨市建设局行业管理网站企业信用信息公示系统广东
  • 网站建设企业网站制作平台学生怎么做网站
  • 网站推广一站式服务百度推广怎么做效果好
  • 网站建设案例 星座外贸网址建站