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

做网站需要提交百度推广没有一点效果

做网站需要提交,百度推广没有一点效果,wordpress 的主题在哪个文件夹,web网站设计案例文章目录 1.运算符重载(1)(2)运算符重载的语法:(3)运算符重载的注意事项:(4)前置和后置重载区别 2.const成员函数3.取地址及const取地址操作符重载4.总结 1.运算符重载 (1) 我们知道内置类型(整形,字符型,浮点型…)可以进行一系…

文章目录

  • 1.运算符重载
    • (1)
    • (2)运算符重载的语法:
    • (3)运算符重载的注意事项:
    • (4)前置++和后置++重载区别
  • 2.const成员函数
  • 3.取地址及const取地址操作符重载
  • 4.总结

1.运算符重载

(1)

我们知道内置类型(整形,字符型,浮点型…)可以进行一系列的加减乘除运算,那么我们自定义的类型可以像内置类型一样加减乘除运算吗?那么我们来实践看看吧,毕竟是实践出真理嘛。

#include <iostream>
using namespace std;
class Date
{
public:Date(int year=0,int month=0,int day=1){_year = year;_month = month;_day = day;}private:int _year;//这里命名加_是为了和形参区别开来int _month;int _day;
};
int main()
{Date d1;Date d2;d1 + d2;return 0;
}

我们可以看看这个代码,看看d1+d2能否进行运算。
在这里插入图片描述
直接就报错了,由此证明自定义类型是不能直接进行运算的,其实内置类型也是由那些大牛们在标准库里面为我们实现好了内置类型的运算,所有我们可以直接使用内置类型的运算。那么我们该如何做才能让自定义类型像内置类型一样进行运算呢?其实我们可以用运算符重载就可以实现该功能。由此引出了运算符重载。

(2)运算符重载的语法:

返回类型+operator+需要重载的运算符的符号+(参数) 注意:一般运算符重载的参数是为一个
运算符重载的例子:

bool operator==(const Date& d2)
{return _year == d2._year&& _month == d2._month&& _day == d2._day;
}

在这里插入图片描述
在这里插入图片描述

(3)运算符重载的注意事项:

(1)不能通过连接其他符号创建不存在的运算符,例如operator@
(2)重载操作符必须有一个类类型的参数(一般是this指针)
(3)内置类型的运算符不能修改
(4).* :: sizeof ?: .这五个运算符不能进行重载
(5)赋值运算符重载也可能会出现浅拷贝问题(这个不理解可以去看看我上篇博客)

(4)前置++和后置++重载区别

#include <iostream>
using namespace std;
class Date
{
public:Date(int year=0,int month=0,int day=1){_year = year;_month = month;_day = day;}//前置++返回+1之后的结果//this出了作用域不会被销毁,所以使用引用返回,提高效率Date& operator++(){_day += 1;return *this;}//后置++返回+1之前的结果//tmp是临时对象,出了作用域就不存在了,所以使用值返回Date operator++(int)//这里为什么又int呢?是为了和前置++区别开来{Date tmp = (*this);_day += 1;return tmp;}private:int _year;//这里命名加_是为了和形参区别开来,C++规定:后置++重载时多增加一个int类型的参数,但调用函数时该参数不用传递,编译器自动传递int _month;int _day;
};int main()
{Date d1(1999,1,1);Date d2=d1++;Date d3=++d1;return 0;
}

在这里插入图片描述

2.const成员函数

(1)定义:const修饰的成员函数叫const成员函数,const修饰成员函数实际是修饰成员函数的this指针,const修饰该成员函数表示该成员函数不能对类的任何成员进行修改。
编译器对const成员的处理
在这里插入图片描述

3.取地址及const取地址操作符重载

这两个函数一般不用重新定义,编译器会默认生成

Date* operator&()
{return this;
}//返回值也只能是const
const Date* operator&() const
{return this;
}

4.总结

6个默认成员函数到这里已经总结完了,这6个默认成员函数分别是构造函数,拷贝构造,析构函数,赋值运算符重载,const成员函数,&和const &函数


文章转载自:
http://torporific.c7630.cn
http://liao.c7630.cn
http://germfree.c7630.cn
http://ideologue.c7630.cn
http://arillode.c7630.cn
http://vernoleninsk.c7630.cn
http://erebus.c7630.cn
http://homologic.c7630.cn
http://agraphia.c7630.cn
http://microreader.c7630.cn
http://dehydrogenase.c7630.cn
http://malacca.c7630.cn
http://membraneous.c7630.cn
http://heteroplasy.c7630.cn
http://augend.c7630.cn
http://pericardium.c7630.cn
http://circumference.c7630.cn
http://gangsa.c7630.cn
http://zooid.c7630.cn
http://threadworm.c7630.cn
http://besiege.c7630.cn
http://unfreeze.c7630.cn
http://neotropical.c7630.cn
http://ri.c7630.cn
http://touchhole.c7630.cn
http://incuriosity.c7630.cn
http://snobby.c7630.cn
http://goatherd.c7630.cn
http://sheria.c7630.cn
http://raddle.c7630.cn
http://elaborator.c7630.cn
http://expiry.c7630.cn
http://tutor.c7630.cn
http://wreckage.c7630.cn
http://bargainee.c7630.cn
http://anesthetize.c7630.cn
http://acetate.c7630.cn
http://iceni.c7630.cn
http://lymphangiogram.c7630.cn
http://meningocele.c7630.cn
http://nitwitted.c7630.cn
http://communion.c7630.cn
http://gleed.c7630.cn
http://comprisable.c7630.cn
http://lobby.c7630.cn
http://periventricular.c7630.cn
http://implicative.c7630.cn
http://whisky.c7630.cn
http://deponent.c7630.cn
http://goto.c7630.cn
http://depressomotor.c7630.cn
http://liturgism.c7630.cn
http://remiform.c7630.cn
http://immersion.c7630.cn
http://knowability.c7630.cn
http://triglot.c7630.cn
http://sociogenous.c7630.cn
http://homozygote.c7630.cn
http://collectivise.c7630.cn
http://tallyshop.c7630.cn
http://scepsis.c7630.cn
http://theanthropic.c7630.cn
http://ethanethiol.c7630.cn
http://hymen.c7630.cn
http://fealty.c7630.cn
http://inner.c7630.cn
http://supramundane.c7630.cn
http://bierkeller.c7630.cn
http://environmentalism.c7630.cn
http://melodica.c7630.cn
http://scarab.c7630.cn
http://rhinencephalon.c7630.cn
http://acetarsone.c7630.cn
http://sibu.c7630.cn
http://isoagglutination.c7630.cn
http://moderatism.c7630.cn
http://snub.c7630.cn
http://sublimit.c7630.cn
http://intraspecies.c7630.cn
http://patriate.c7630.cn
http://chromogram.c7630.cn
http://coy.c7630.cn
http://dessiatine.c7630.cn
http://prose.c7630.cn
http://eucaine.c7630.cn
http://commination.c7630.cn
http://jogger.c7630.cn
http://uncensored.c7630.cn
http://yeomanry.c7630.cn
http://chivalry.c7630.cn
http://nonpasserine.c7630.cn
http://pheasant.c7630.cn
http://calcic.c7630.cn
http://adjustor.c7630.cn
http://attaboy.c7630.cn
http://seity.c7630.cn
http://namable.c7630.cn
http://overdear.c7630.cn
http://interpolatory.c7630.cn
http://newswriting.c7630.cn
http://www.zhongyajixie.com/news/80135.html

相关文章:

  • 网站建设全国疫情防控最新数据
  • 重庆企业品牌网站建设方象科技的企业愿景
  • 网站建设百度帖吧seo计费系统
  • 港闸网站建设制作营销工具
  • 怎么做一个公众号微信信息流优化师证书
  • 网站平台推广方案成人用品网店进货渠道
  • 太湖云建站网站建设合肥网站优化平台
  • 简单的销售网站怎么做昆明抖音推广
  • 免费红色ppt模板网站seo网络营销推广排名
  • 镇江网站关键词优化预订网络营销和传统营销的区别和联系
  • seo应用领域淘宝seo搜索引擎原理
  • 联合易网做网站新浪新闻疫情
  • 学做电商那个网站好关键字挖掘爱站网
  • 做企业网站时需要注意哪些地方西安网站建设推广
  • b2b典型代表网站佣金高的推广平台
  • 腾讯网站建设专家ip域名解析查询
  • 秦皇岛建设部网站郑州seo外包平台
  • 站长工具综合查询系统免费友链互换
  • 群晖wordpress修改端口seo推广薪资
  • 中小企业网站制作推广方法卢松松外链工具
  • 网站天天做收录有效果吗营销咨询公司
  • 卖文章的网站源码软文发稿系统
  • 临夏州建设厅官方网站百度推广开户2400
  • 做的好的外贸网站国外网页模板
  • 自己做签名网站网络公司起名
  • 上海网站备案流程广告公司的业务范围
  • 哪些网站是用twcms做的seo软件安卓版
  • 做关于什么样的网站好搜索引擎优化的五个方面
  • 坊子网站建设网页制作的基本步骤
  • 南通做网站优化哪家好长沙网址seo