这是字符串类。
方法/属性 | 意义 |
---|---|
void resize(n, x=T()) | 重设长度 |
size_type size() size_type length() |
返回长度 |
c_str() | 返回类似 char * 地址,只读 |
size_type max_size() | 最大长度 |
bool empty() | 是否空 |
reference at(pos) | 返回指定位置的字符 |
reference operator[](pos) | 返回指定位置的字符 |
+=
append(...) |
字符串连接 |
insert(...) | 插入字符/串 |
replace(...) | 替换字符/串 |
copy(char *,长度,从) | 复制字符串 |
swap(string) | 交换 |
find(...)
rfind(...) find_first_of(...) find_last_of(...) |
查找字符/串 |
string substr(pos=0, len=npos) | 返回子字符串 |
compare(...) | 比较 |
方法 | 意义 |
---|---|
basic_string& append(const basic_string& str) | |
basic_string& append(const basic_string& str, size_type pos, size_type n) | |
basic_string& append(const E *s, size_type n) | |
basic_string& append(const E *s) | |
basic_string& append(size_type n, E c) | 附加 n 个字符 c |
返回都是 string 类型。
方法 | 意义 |
---|---|
insert(插入位置,字符串) | 插入字符串 |
insert(插入位置,字符串,从,长度) | |
insert(插入位置,字符串,长度) | |
insert(插入位置,字符串地址) | |
insert(插入位置,字符数,字符) | 插入 n 个字符 c |
返回都是 string 类型。
方法 | 意义 |
---|---|
replace(替换位置,替换长度,字符串) | |
replace(替换位置,替换长度,字符串,从,长度) | |
replace(替换位置,替换长度,字符串,长度) | |
replace(替换位置,替换长度,字符串地址) | |
replace(替换位置,替换长度,字符数,字符) | 替换为 n 个字符 c |
返回都是 size_type 类型。
方法 | 意义 |
---|---|
size_type find(const basic_string& str, size_type pos = 0) const | |
size_type find(const E *s, size_type pos, size_type n) const | |
size_type find(const E *s, size_type pos = 0) const | |
size_type find(E c, size_type pos = 0) const | |
size_type rfind(const basic_string& str, size_type pos = npos) const | |
size_type rfind(const E *s, size_type pos, size_type n = npos) const | |
size_type rfind(const E *s, size_type pos = npos) const | |
size_type rfind(E c, size_type pos = npos) const | |
size_type find_first_of(const basic_string& str, size_type pos = 0) const | |
size_type find_first_of(const E *s, size_type pos, size_type n) const | |
size_type find_first_of(const E *s, size_type pos = 0) const | |
size_type find_first_of(E c, size_type pos = 0) const | |
size_type find_last_of(const basic_string& str, size_type pos = npos) const | |
size_type find_last_of(const E *s, size_type pos, size_type n = npos) con/t | |
size_type find_last_of(const E *s, size_type pos = npos) const | |
size_type find_last_of(E c, size_type pos = npos) const | |
size_type find_first_not_of(const basic_string& str, size_type pos = 0) const | |
size_type find_first_not_of(const E *s, size_type pos, size_type n) const | |
size_type find_first_not_of(const E *s, size_type pos = 0) const | |
size_type find_first_not_of(E c, size_type pos = 0) const | |
size_type find_last_not_of(const basic_string& str, size_type pos = npos) const | |
size_type find_last_not_of(const E *s, size_type pos, size_type n) const | |
size_type find_last_not_of(const E *s, size_type pos = npos) const | |
size_type find_last_not_of(E c, size_type pos = npos) const |
方法 | 意义 |
---|---|
int compare(const basic_string& str) const | |
int compare(size_type p0, size_type n0, const basic_string& str) | |
int compare(size_type p0, size_type n0, const basic_string& str, size_type pos, size_type n) | |
int compare(const E *s) const | |
int compare(size_type p0, size_type n0, const E *s) const | |
int compare(size_type p0, size_type n0, const E *s, size_type pos) const |