当前位置:网站首页>string类简介
string类简介
2022-08-04 05:16:00 【叽里呱啦呱】
简介: IOS/ANSI C++标准通过添加string类拓展了C++库,因此现在可以用string类型的变量(c++中称为对象)而不仅是字符数组来储存字符串,string类使用起来比数组简单,同时也提供了将字符串组作为一种数据类型的表示方式。
#要使用string类,必须要在程序中包含头文件string,string类位于命名空间std中。
使用string对象的方式与字符数组相同,但是类设计让程序可以自动处理string的大小,因此与数组相比string对象也更加安全
赋值,拼接,附值
可以像普通变量一样赋值,但是数组不能
string类简化了子字符串的合并操作可以使用运算符+将两个string对象合并起来,还可以用运算符+=将字符串附加到string对象的末尾
string类的其他操作
确定字符串的长度name.size(),c++string对象使用对象名和句点运算符来指出使用哪个字符串
输出均与字符数组一样,但整行输入有些区别,是这样表示的getline(cin,str)
其他形式的字符串字面值(有待补充)
边栏推荐
- C Expert Programming Chapter 5 Thinking about Linking 5.3 5 Special Secrets of Library Linking
- 7-3 LVS+Keepalived Cluster Description and Deployment
- Typora 使用保姆级教程 | 看这一篇就够了 | 历史版本已被禁用
- 结构体指针知识要点总结
- C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.1 Arrays are not pointers
- Cache pool of unity framework
- The idea setting recognizes the .sql file type and other file types
- centos 安装postgresql13 指定版本
- 转:管理是对可能性的热爱,管理者要有闯进未知的勇气
- 附加:对于“与数据表对应的实体类“,【面对MongoDB时,使用的@Id等注解】和【以前面对MySQL时,使用的@Id等注解】,是不同的;
猜你喜欢

3面头条,花7天整理了面试题和学习笔记,已正式入职半个月

Towards Real-Time Multi-Object Tracking(JDE)

Typora 使用保姆级教程 | 看这一篇就够了 | 历史版本已被禁用

符号表

一个对象引用的思考

3000字,一文带你搞懂机器学习!

There is an 8 hour difference between the docker installation of mysql and the host.

应届生软件测试薪资大概多少?

What is the salary of a software testing student?

Resolved error: npm WARN config global `--global`, `--local` are deprecated
随机推荐
go module的介绍与应用
el-Select 选择器 底部固定
Introduction and application of go module
Performance testing with Loadrunner
Programming hodgepodge (4)
Will the 2023 PMP exam use the new version of the textbook?Reply is here!
C Expert Programming Chapter 5 Thinking about Linking 5.3 5 Special Secrets of Library Linking
C专家编程 第5章 对链接的思考 5.2 动态链接的优点
应届生软件测试薪资大概多少?
static在不同位置定义变量居然还有不同的含义?
2023年PMP考试会用新版教材吗?回复来了!
Redis common interview questions
2022 software test interview questions The latest ByteDance 50 real interview questions, 15k have been won after brushing, with explanation + Q&A
8款最佳实践,保护你的 IaC 安全!
DataTable uses Linq for grouping and summarization, and converts the Linq result set into DataTable
redis中常见的面试题
【21 Days Learning Challenge】Direct Insertion Sort
力扣:62.不同路径
3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection