当前位置:网站首页>The string class introduction
The string class introduction
2022-08-04 05:35:00 【quack quack】
Introduction: The IOS/ANSI C++ standard extends the C++ library by adding the string class, so you can now use string-type variables (called objects in C++)Rather than just storing strings as character arrays, the string class is simpler to use than arrays, and also provides a way to represent groups of strings as a data type.
#To use the string class, the header file string must be included in the program, and the string class is located in the namespace std.
Use string objects in the same way as character arrays, but the class design allows the program to automatically handle the size of the string, so string objects are also safer than arrays
Assignment, splicing, adding value
You can assign values like normal variables, but arrays cannot
The string class simplifies merging of substrings. You can use the operator + to combine two string objects, and you can use the operator += to append strings toend of string object
Other operations of the string class
Determine the length of the string name.size(), the c++ string object uses the object name and the period operator to indicate which string to use
The output is the same as the character array, but the input of the whole line is somewhat different, which is expressed as getline(cin,str)
Other forms of string literals (to be added)
边栏推荐
猜你喜欢
随机推荐
8、自定义映射resultMap
Cannot read properties of null (reading ‘insertBefore‘)
[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
4.1 声明式事务之JdbcTemplate
static在不同位置定义变量居然还有不同的含义?
数的划分之动态规划
string类简介
C语言 -- 操作符详解
C Expert Programming Chapter 4 The Shocking Fact: Arrays and Pointers Are Not the Same 4.5 Other Differences Between Arrays and Pointers
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.4 使声明与定义相匹配
谷粒商城-基础篇(项目简介&项目搭建)
7.16 Day22---MYSQL(Dao模式封装JDBC)
力扣:746. 使用最小花费爬楼梯
腾讯136道高级岗面试题:多线程+算法+Redis+JVM
读者让我总结一波 redis 面试题,现在肝出来了
想低成本保障软件安全?5大安全任务值得考虑
编程大杂烩(三)
OpenSSF 安全计划:SBOM 将驱动软件供应链安全
一个对象引用的思考
【云原生--Kubernetes】Pod资源管理与探针检测