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

重庆外贸网站建设wordpress更改文件上传目录

重庆外贸网站建设,wordpress更改文件上传目录,wordpress 4.9.1,wordpress的cute主题前言 之前我们已经学习了四个默认成员函数#xff08;构造、析构、拷贝构造、运算符重载#xff09; 今天我们就来尝试用已经学到的知识进行日期类的完整实现 提示#xff1a; 依然是分成三个文件来写 只是在讲解的时候就不区分文件了 完整的代码在文章最后 并且之前文章中…前言 之前我们已经学习了四个默认成员函数构造、析构、拷贝构造、运算符重载 今天我们就来尝试用已经学到的知识进行日期类的完整实现 提示 依然是分成三个文件来写 只是在讲解的时候就不区分文件了 完整的代码在文章最后 并且之前文章中提到的知识在此不会再详细介绍 Date类创建 //对类的成员变量和函数进行声明 class Date { public:Date(int year 1, int month 1, int day 1);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);private:int _year;int _month;int _day; };构造函数 //一个简单的构造函数 Date::Date(int year, int month, int day) {_year year;_month month;_day day;//_year _month _day前加不加this-都可以 加上只是为了方便理解 }比较功能 bool Date::operator(const Date d) {return _year d._year _month d._month _day d._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){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); }! 那就是的逻辑取反 bool Date::operator!(const Date d) {return !(*this d); }运算功能 辅助函数 创建一个函数用于辅助计算 int GetMonthDay(int year, int month){assert(month 0 month 13);static int monthDays[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 monthDays[month];}类天数 Date Date::operator(int 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原本不存在 是新创建的//相当于 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 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 (*this d){int flag -1;swap(d, *this);}int n 0;while (min ! max){min;n;}return n * flag; }输入输出 对于输入输出 cpp规定 成员函数的重载this是第一个参数所以Date自动成为第二个参数所以他就只能是左操作数了 我们可以写成全局函数 但是不行的因为成员变量是私有的 无法访问 输出流插入 我们可以用友元函数来解决这个问题 详见另一篇文章 代码如下 //在类里面声明 friend ostream operator(ostream out, const Date d);//在类外面实现 ostream operator(ostream out, const Date d) {out d._year 年 d._month 月 d._day 日 endl;return out; }对于流插入的详细介绍到后期再详细介绍 现在只是了解即可 输入流提取 friend istream operator(istream out, Date d); //d不加constistream operator(istream out, Date d) {cout 输入年月日 endl;in d._year d._month d._day;return in; }检查 实现一个check函数来检查输入的日期是否合法 //用于构造函数和流提取中 bool CheckInvalid() {if(_year 0 || _month 1 || _month 12 || _day 1 || _day GetMonthDay(_year, _month))return false; }结语 关于日期类的简单实现到这里就结束了 属于是综合了前面的众多知识 还是需要好好消化一番的 希望对你有帮助 我们下次见~~
http://www.zqtcl.cn/news/191290/

相关文章:

  • 企业公司官网网站做网站怎样做
  • 网站建设 今网科技电商网站建设布局
  • 最优惠的网站优化管理培训机构
  • p2p网站建设广州深圳网站设计公司哪家好
  • 福州网站设计哪里好泰安网站建设入门推荐
  • 北京网站软件制作外卖网站开发
  • 个人网站建设与实现建立个公司网站
  • 南昌招商网站建设临沂兰山建设局网站
  • 母婴网站建设怎么样可以做网站
  • 二手车 网站开发wordpress 定时 检查
  • 淮南官网济南seo优化外包
  • 沈阳网站建设莫道网络网站建设常用六大布局
  • 网站建设外文版要求网站关键字优化销售
  • 马来西亚做公路投标网站设计网页多少钱
  • 织梦网站多少钱广告多的网站
  • 济南网站建站模板深圳南园网站建设
  • 国家免费技能培训官网白杨seo博客
  • 福州seo网站建设微服务网站
  • 网站宽度 像素长沙电商运营培训
  • 备案上个人网站和企业网站的区别app开发多少钱一个
  • 有限公司网站建设 中企动力佛山培训机构招生方案
  • 扫黄打非网站建设专业的高端网站制作公司
  • 做自媒体发视频用哪些网站江西网站建设哪家好
  • wordpress用户列表南宁百度seo排名优化
  • 做网站时如何写接口文档上海网站设计建设公司
  • 网站小图标怎么制作平面设计素材网站推荐
  • 多元网络兰州网站建设惠州网页建站模板
  • 网站建设中首页模板下载网页制作模板保存
  • 宁夏做网站的江苏网站建设的案例展示
  • 网站功能需求文档如何免费域名注册