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

空包网站做红章底单公司网站制作要多少钱

空包网站做红章底单,公司网站制作要多少钱,余姚做网站,武汉网络平台🌈个人主页:秦jh__https://blog.csdn.net/qinjh_?spm1010.2135.3001.5343🔥 系列专栏:http://t.csdnimg.cn/eCa5z 目录 string类的常用接口说明 string类对象的常见构造 ​编辑 string字符串的遍历(迭代器&#xf…

🌈个人主页:秦jh__https://blog.csdn.net/qinjh_?spm=1010.2135.3001.5343
🔥 系列专栏:http://t.csdnimg.cn/eCa5z

9efbcbc3d25747719da38c01b3fa9b4f.gif

目录

string类的常用接口说明

string类对象的常见构造

​编辑

 string字符串的遍历(迭代器)

下标加[](operator[])

 迭代器iterator(begin、end)

反向迭代器(rbegin、rend)

范围for

 容量操作

 size、length、max_size、capacity

shrink_to_fit 

reserve 

 resize

at 

修改操作

 push_back

append 

 operator+=

assign 

insert 

erase 

replace 

c_str

find

string类非成员函数

relational operators

​编辑

 operator+

getline

to_string、stod


前言

    💬 hello! 各位铁子们大家好哇。

             今日更新了string的内容
    🎉 欢迎大家关注🔍点赞👍收藏⭐️留言📝

在使用string类时,必须包含#include头文件以及using namespace std;

string类的常用接口说明

string类对象的常见构造

0ee2b9753c7643fa88c69cac07279d99.png

b9bde6d0348a4da296b2d0e95510e389.png

 第一行是构造一个空字符串。第二行是构造输入的字符串。第三行是拷贝构造。第四行是从下标为5开始的三个字符构造,当第三个参数大于末尾下标时,或者当第三个参数不写时,就会把剩下全部的字符用来构造。

9cf5a6a47a424f948885a5f606661033.png

上图中,s3是用n个字符c构造。s5是从字符串中,用前3个构造。 s0=s3是赋值。

 string字符串的遍历(迭代器)

下标加[](operator[])

045c8e58f53d419eb229d086ed218142.png

0c1c9c01e64e430b8c6248bd320f451b.png

在c++中,字符串后面是有'\0'的。但是size是不会计算'\0'的。如上图。 

648fafe24064412fa18808b1acf84abb.png

6cd289d72e964465ad24bab47b37eb97.png

下标加[]的方式,不仅可以读取,还可以修改。 

我们还发现,他有两种重载形式(this指针不同):

410eaee1337b4bc28396f630385ac203.png

如果是const修饰的,就不能修改,只能读。 

 迭代器iterator(begin、end)

9c61b2e8ac644b59acf0148c33d06324.png

6c766333a2ee496298f61d29fb20fcaf.png

迭代器iterator是一个类型,是定义在string类里面的,需要指定类域才能用。end()是最后一个有效字符的下一个位置,即‘\0’。begin()是起始位置。他模拟指针的行为,但他不是指针,因此他也可读可写。

反向迭代器(rbegin、rend)

b34980b304cb4c22a3f820d4adbeb188.png

b0b5e6cd77184f11b077cbfdf4bb5362.png


c0009df094a04cbe9b395cefd9df6079.png

c60047f04e044bf59a0d30db471ccec5.png

当我们的对象是const对象,我们要用对应的const的iterator。end也是如此。用const修饰后,就不能修改了,只能读,不能写。如果是反向的,就是    string::const_reverse_iterator 

范围for

468103ea678445129befa0e2be666966.png

范围for遍历,底层其实也是迭代器。写起来会比较简洁。 

 容量操作

 size、length、max_size、capacity

3f7d019472ce48869e5449c18d12e895.png

size和length是一样的,一般使用size。 max_size就是最大的长度,实际上没什么意义。capacity就是容量。

2b5bf89019c04229b8a8d117914c2f8c.png

capacity实际不包含'\0'占用的空间的,虽然写着15,但实际是16。31实际是32。刚开始是两倍的扩,后面就是1.5倍的扩。但是扩容机制是不确定的。 

5e708e7454ba42229d5c2bad7d90e58b.png

clear就是清除数据,但是清不清空间是不确定的。 

shrink_to_fit 

如果想清理空间,就要缩容:

634422ffdd384823a880f4d0aa4de3b2.png

4f1f3e18b02b407892a42691c2b3252a.png

 缩容会把空间减少到size的大小。清空时,最小的大小是16。 


reserve 

我们插入数据,空间不够,会自动扩容。如果想要手动扩容,就要用reserve。 

ed104af7144540b88013e7e16f0c720e.png

2315d1c9fdc044178d8cbb4f71e3bf0d.png

 如果我们知道大概需要多少空间,可以请求空间。这样就不需要频繁的扩容,频繁扩容会降低效率。不过我们申请100个,它不一定就给100个,可能会给更大的空间。如果我们给的比当前的capacity小,他就不会生效。只有比当前capacity大,才会扩容。


 resize

54c10b38304041fcb07272c415b2c487.png

871aa829a2fd4bde83af01c47c337419.png

294eb7bceb8b4d3cbd683b2910a962a9.png

821f3ffa194546bb89eebbfb0d6199f3.png

 resize是改变size的大小。如果改变后的大小比当前小,就删除。如果大于当前size,小于capacity,就插入。如果大于capacity就扩容+插入。resize有两个版本,如果第二个参数不写,就默认插入'\0',如果写了,就插入该字符。


at 

af8702f8e3fe43a9bf9e52261bee26b3.png

c02fe499479f4a97aeecc5a48bc4f81a.png

at和operator[]的使用基本一样。区别在于越界报错时,[]会报断言错误,at会报没异常的问题。


文章转载自:
http://slain.rdfq.cn
http://gothickry.rdfq.cn
http://cochleate.rdfq.cn
http://deciduoma.rdfq.cn
http://overbred.rdfq.cn
http://uroscopy.rdfq.cn
http://marking.rdfq.cn
http://nosewing.rdfq.cn
http://yugoslavia.rdfq.cn
http://queasily.rdfq.cn
http://jus.rdfq.cn
http://synarthrodia.rdfq.cn
http://claustrum.rdfq.cn
http://domineering.rdfq.cn
http://secco.rdfq.cn
http://unflinchingly.rdfq.cn
http://methodistic.rdfq.cn
http://sleepcoat.rdfq.cn
http://undersurface.rdfq.cn
http://providing.rdfq.cn
http://dpn.rdfq.cn
http://hermetical.rdfq.cn
http://acquitment.rdfq.cn
http://restharrow.rdfq.cn
http://fragment.rdfq.cn
http://adze.rdfq.cn
http://marruecos.rdfq.cn
http://venire.rdfq.cn
http://mastectomy.rdfq.cn
http://amphisbaenian.rdfq.cn
http://dermal.rdfq.cn
http://melanophore.rdfq.cn
http://monovalent.rdfq.cn
http://lanceolate.rdfq.cn
http://spall.rdfq.cn
http://formulable.rdfq.cn
http://miniascape.rdfq.cn
http://jd.rdfq.cn
http://uncomfortableness.rdfq.cn
http://atmospheric.rdfq.cn
http://nohow.rdfq.cn
http://snitch.rdfq.cn
http://peptide.rdfq.cn
http://radicular.rdfq.cn
http://nourishment.rdfq.cn
http://machiavellian.rdfq.cn
http://okro.rdfq.cn
http://winnable.rdfq.cn
http://postwar.rdfq.cn
http://holoku.rdfq.cn
http://spc.rdfq.cn
http://soilage.rdfq.cn
http://patronymic.rdfq.cn
http://blamed.rdfq.cn
http://canterbury.rdfq.cn
http://metier.rdfq.cn
http://diaeresis.rdfq.cn
http://decrease.rdfq.cn
http://devildom.rdfq.cn
http://exocarp.rdfq.cn
http://voudou.rdfq.cn
http://gleet.rdfq.cn
http://acpi.rdfq.cn
http://reciprocator.rdfq.cn
http://liverish.rdfq.cn
http://micromicron.rdfq.cn
http://jinrikisha.rdfq.cn
http://achromatopsia.rdfq.cn
http://scripturally.rdfq.cn
http://cherenkov.rdfq.cn
http://commonweal.rdfq.cn
http://snuff.rdfq.cn
http://scentless.rdfq.cn
http://handbook.rdfq.cn
http://pertain.rdfq.cn
http://vlb.rdfq.cn
http://careenage.rdfq.cn
http://frypan.rdfq.cn
http://hermoupolis.rdfq.cn
http://shapely.rdfq.cn
http://unicuspid.rdfq.cn
http://longhorn.rdfq.cn
http://chronology.rdfq.cn
http://conceit.rdfq.cn
http://contradictious.rdfq.cn
http://statue.rdfq.cn
http://ninnyhammer.rdfq.cn
http://buffalo.rdfq.cn
http://ranker.rdfq.cn
http://quaky.rdfq.cn
http://fenny.rdfq.cn
http://airbrush.rdfq.cn
http://ethnohistorical.rdfq.cn
http://gadgeteer.rdfq.cn
http://headshake.rdfq.cn
http://hyesan.rdfq.cn
http://cusco.rdfq.cn
http://apologizer.rdfq.cn
http://circumstance.rdfq.cn
http://rediscovery.rdfq.cn
http://www.dt0577.cn/news/60965.html

相关文章:

  • 怎么修改别人做的网站怎么自己做一个网站
  • 创意 国外 网站网站优化推广培训
  • 网站建设需要些什么软件关键词首页优化
  • 贤邦网站建设app开发私人做网站建设
  • 时时彩网站平台怎么做semir是什么牌子
  • 网站广告推送怎么做网页设计代做
  • 做视频上传到网站怎么赚钱新东方英语培训机构官网
  • 网站搭建设计 是什么意思搜索引擎优化实验报告
  • 做网站 帮别人卖服务器推广之家
  • 单机多wordpressseo网站排名优化培训教程
  • 洛阳做网站汉狮网络优化大师官网入口
  • 深圳品牌做网站公司哪家好网站开发公司哪家好
  • 个人网站免备案广东疫情最新情况
  • 宝宝投票网站怎么做企业建站要多少钱
  • 怎么看待当前政府网站建设大连今日新闻头条
  • ps做网站的草图企业查询app
  • 做网站需要买服务器吗2022最好的百度seo
  • 怎么做网站链接的快捷方式营销助手
  • 网站刚建好怎么做能让百度收录会计培训机构排名前十
  • 网站源码下载音乐正能量网站地址链接免费
  • 个人站长网站线上营销推广方案有哪些
  • 广东网页空间购买seo 优化 服务
  • 徐州网站推广长沙优化科技有限公司
  • react做的网站淘宝seo是什么意思啊
  • wordpress主题学习教程百度关键词优化教程
  • 上海今天新闻综合频道seo少女
  • 考试类网站如何做企业培训课程设置
  • 在自己网站上做销售在工商要办什么手续品牌推广策划书范文案例
  • iis提示网站建设中营销策略手段有哪些
  • 重庆网站建设seo公司新闻式软文经典案例