- C++
如何使用string类中的成员函数?
- @ 2024-12-7 21:41:07
- 构造函数
- 默认构造函数
- 功能:创建一个空的字符串对象。
- 示例:
在这个示例中,#include <iostream> #include <string> int main() { std::string str; std::cout << "The string is empty: " << (str.empty()? "true" : "false") << std::endl; return 0; }str是使用默认构造函数创建的空字符串。通过empty函数来验证它是否为空。
- 带参数的构造函数(以C - 字符串初始化)
- 功能:可以使用C - 字符串(
char*)来初始化string对象。 - 示例:
这里,#include <iostream> #include <string> int main() { char c_str[]="Hello"; std::string str(c_str); std::cout << str << std::endl; return 0; }c_str是一个C - 字符串,通过带参数的构造函数将其内容复制到string对象str中,然后输出str。
- 功能:可以使用C - 字符串(
- 拷贝构造函数
- 功能:用于创建一个新的
string对象,它是另一个string对象的副本。 - 示例:
在这个例子中,#include <iostream> #include <string> int main() { std::string str1 = "World"; std::string str2(str1); std::cout << str2 << std::endl; return 0; }str2是通过拷贝构造函数从str1创建的,str2的内容与str1相同。
- 功能:用于创建一个新的
- 默认构造函数
- 长度相关函数:
length和size- 功能:这两个函数都用于返回字符串中字符的数量。它们的功能是完全相同的,只是名字不同,方便不同编程习惯的人使用。
- 示例:
这里分别使用#include <iostream> #include <string> int main() { std::string str = "Hello, World"; std::cout << "Length of the string: " << str.length() << std::endl; std::cout << "Size of the string: " << str.size() << std::endl; return 0; }length和size函数来获取并输出字符串str的长度。
- 访问字符的函数:
operator[]和atoperator[]函数- 功能:可以通过下标来访问字符串中的单个字符,就像访问数组元素一样。它不会进行边界检查,所以如果下标超出范围,可能会导致程序崩溃或产生未定义行为。
- 示例:
这里通过#include <iostream> #include <string> int main() { std::string str = "abc"; char c = str[1]; std::cout << c << std::endl; return 0; }operator[]函数获取字符串str中下标为1的字符(即b)并输出。
at函数- 功能:也用于访问字符串中的单个字符,但它会进行边界检查。如果下标超出范围,会抛出
std::out_of_range异常。 - 示例:
在这个示例中,同样是获取下标为1的字符。但是使用了#include <iostream> #include <string> int main() { std::string str = "abc"; try { char c = str.at(1); std::cout << c << std::endl; } catch (std::out_of_range& e) { std::cerr << "Error: " << e.what() << std::endl; } return 0; }at函数,并且包含了异常处理部分,以应对可能出现的下标越界情况。
- 功能:也用于访问字符串中的单个字符,但它会进行边界检查。如果下标超出范围,会抛出
- 字符串拼接函数:
append和operator+append函数- 功能:用于在字符串的末尾添加另一个字符串或字符序列。
- 示例:
这里,#include <iostream> #include <string> int main() { std::string str1 = "Hello"; std::string str2 = " World"; str1.append(str2); std::cout << str1 << std::endl; return 0; }str1通过append函数在末尾添加了str2的内容,最后输出拼接后的字符串。
operator+函数- 功能:可以使用
+运算符来拼接两个字符串。它返回一个新的字符串,而原字符串不变。 - 示例:
这个示例中,通过#include <iostream> #include <string> int main() { std::string str1 = "Good"; std::string str2 = " morning"; std::string str3 = str1 + str2; std::cout << str3 << std::endl; return 0; }+运算符将str1和str2拼接成一个新的字符串str3并输出。
- 功能:可以使用
- 比较函数:
compare和比较运算符(==、<等)compare函数- 功能:用于比较两个字符串。它返回一个整数值,根据这个值可以判断两个字符串的大小关系。如果返回值小于0,表示当前字符串小于被比较的字符串;如果返回值等于0,表示两个字符串相等;如果返回值大于0,表示当前字符串大于被比较的字符串。
- 示例:
这里使用#include <iostream> #include <string> int main() { std::string str1 = "abc"; std::string str2 = "abd"; int result = str1.compare(str2); if (result < 0) { std::cout << "str1 is less than str2" << std::endl; } else if (result == 0) { std::cout << "str1 is equal to str2" << std::endl; } else { std::cout << "str1 is greater than str2" << std::endl; } return 0; }compare函数比较str1和str2,并根据返回值输出比较结果。
- 比较运算符(
==、<等)- 功能:可以直接使用比较运算符来比较两个字符串。这些运算符在内部调用了
compare函数来进行比较。 - 示例:
这个示例中,使用#include <iostream> #include <string> int main() { std::string str1 = "abc"; std::string str2 = "abc"; if (str1 == str2) { std::cout << "str1 is equal to str2" << std::endl; } return 0; }==运算符来判断str1和str2是否相等。
- 功能:可以直接使用比较运算符来比较两个字符串。这些运算符在内部调用了
- 查找函数:
find和rfindfind函数- 功能:用于在字符串中查找指定的子字符串或字符。它返回第一次找到的位置(从字符串开头开始计数的下标),如果没有找到,则返回
std::string::npos。 - 示例:
这里使用#include <iostream> #include <string> int main() { std::string str = "Hello, World"; size_t position = str.find("World"); if (position!= std::string::npos) { std::cout << "Substring found at position: " << position << std::endl; } else { std::cout << "Substring not found" << std::endl; } return 0; }find函数在str中查找"World"子字符串,并根据返回值判断是否找到以及输出找到的位置。
- 功能:用于在字符串中查找指定的子字符串或字符。它返回第一次找到的位置(从字符串开头开始计数的下标),如果没有找到,则返回
rfind函数- 功能:与
find函数类似,但它是从字符串的末尾开始查找指定的子字符串或字符,返回最后一次找到的位置(从字符串开头开始计数的下标),如果没有找到,也返回std::string::npos。 - 示例:
在这个示例中,使用#include <iostream> #include <string> int main() { std::string str = "Hello, World"; size_t position = str.rfind("o"); if (position!= std::string::npos) { std::cout << "Substring found at position: " << position << std::endl; } else { std::cout << "Substring not found" << std::endl; } return 0; }rfind函数从str的末尾开始查找字符o,并根据返回值输出结果。
- 功能:与
- 替换函数:
replace- 功能:用于替换字符串中的一部分内容。它可以指定要替换的起始位置、长度和替换后的内容。
- 示例:
这里使用#include <iostream> #include <string> int main() { std::string str = "I like coffee"; str.replace(7, 6, "tea"); std::cout << str << std::endl; return 0; }replace函数将str中从下标7开始的长度为6的子字符串(即coffee)替换为tea,然后输出替换后的字符串。
7 条评论
-
admin SU @ 2024-12-15 15:38:04
isalnum函数- 功能:
- 用于判断一个字符是否是字母数字字符,即是否为字母(
A - Z、a - z)或者数字(0 - 9)。
- 用于判断一个字符是否是字母数字字符,即是否为字母(
- 函数原型(以C++为例):
int isalnum(int c);,参数c是要检查的字符(以ASCII码值的形式传入),如果c是字母数字字符,函数返回非零值(相当于true),否则返回0(相当于false)。
- 示例:
- 功能:
#include <iostream> #include <cctype> using namespace std; int main() { char ch1 = 'A'; char ch2 = '9'; char ch3 = '$'; cout << "isalnum('A')返回值: " << isalnum(ch1) << endl; cout << "isalnum('9')返回值: " << isalnum(ch2) << endl; cout << "isalnum('$')返回值: " << isalnum(ch3) << endl; return 0; }- 在这个例子中,`isalnum(ch1)`和`isalnum(ch2)`会返回非零值,因为`A`是字母,`9`是数字,而`isalnum(ch3)`返回`0`,因为`$`既不是字母也不是数字。isspace函数- 功能:
- 用于判断一个字符是否为空白字符,包括空格
' '、制表符'\t'、换行符'\n'、垂直制表符'\v'、换页符'\f'和回车符'\r'。
- 用于判断一个字符是否为空白字符,包括空格
- 函数原型(以C++为例):
int isspace(int c);,参数c是要检查的字符(以ASCII码值传入),如果c是空白字符,函数返回非零值,否则返回0。
- 示例:
- 功能:
#include <iostream> #include <cctype> using namespace std; int main() { char ch1 = ' '; char ch2 = 'a'; cout << "isspace(' ')返回值: " << isspace(ch1) << endl; cout << "isspace('a')返回值: " << isspace(ch2) << endl; return 0; }- 这里`isspace(ch1)`返回非零值,因为`ch1`是空格,而`isspace(ch2)`返回`0`,因为`a`不是空白字符。isdigit函数- 功能:
- 专门用于判断一个字符是否是数字字符,即是否在
0 - 9范围内。
- 专门用于判断一个字符是否是数字字符,即是否在
- 函数原型(以C++为例):
int isdigit(int c);,参数c是要检查的字符(以ASCII码值传入),如果c是数字,函数返回非零值,否则返回0。
- 示例:
- 功能:
#include <iostream> #include <cctype> using namespace std; int main() { char ch1 = '5'; char ch2 = 'a'; cout << "isdigit('5')返回值: " << isdigit(ch1) << endl; cout << "isdigit('a')返回值: " << isdigit(ch2) << endl; return 0; }- 此例中`isdigit(ch1)`返回非零值,因为`5`是数字,`isdigit(ch2)`返回`0`,因为`a`不是数字。ispunct函数- 功能:
- 用于判断一个字符是否是标点符号,标点符号包括除了字母、数字和空白字符之外的可打印字符。
- 函数原型(以C++为例):
int ispunct(int c);,参数c是要检查的字符(以ASCII码值传入),如果c是标点符号,函数返回非零值,否则返回0。
- 示例:
- 功能:
#include <iostream> #include <cctype> using namespace std; int main() { char ch1 = '.'; char ch2 = 'A'; cout << "ispunct('.)返回值: " << ispunct(ch1) << endl; cout << "ispunct('A')返回值: " << ispunct(ch2) << endl; return 0; }- 这里`ispunct(ch1)`返回非零值,因为`'.'`是标点符号,`ispunct(ch2)`返回`0`,因为`A`不是标点符号。 -
@ 2024-12-15 15:37:51
tolower函数- 功能概述
- 在C和C++ 中,
tolower函数用于将大写字母转换为小写字母。如果传入的字符不是大写字母,函数通常会返回原始字符不变。
- 在C和C++ 中,
- 函数原型(以C++为例)
int tolower(int c);(在C语言中也类似)。这里的参数c是要转换的字符(以其ASCII码值的形式传入),返回值是转换后的字符(也是以ASCII码值的形式返回)。
- 使用示例
- 以下是一个C++ 示例代码:
- 功能概述
#include <iostream> #include <cctype> using namespace std; int main() { char ch1 = 'A'; char ch2 = 'a'; char ch3 = '5'; char lower_ch1 = tolower(ch1); char lower_ch2 = tolower(ch2); char lower_ch3 = tolower(ch3); cout << "将 'A' 转换为小写字母: " << lower_ch1 << endl; cout << "将 'a' 转换为小写字母(本身就是小写,不变): " << lower_ch2 << endl; cout << "将 '5' 转换为小写字母(非大写字母,不变): " << lower_ch3 << endl; return 0; }- 在这个示例中,`tolower(ch1)`会将大写字母`A`(ASCII码值为65)转换为小写字母`a`(ASCII码值为97)。而对于已经是小写字母的`ch2`和非字母的`ch3`,函数返回原始字符。toupper函数- 功能概述
- 与
tolower相反,toupper函数用于将小写字母转换为大写字母。如果传入的字符不是小写字母,函数通常会返回原始字符不变。
- 与
- 函数原型(以C++为例)
int toupper(int c);(在C语言中也类似)。参数c是要转换的字符(以ASCII码值传入),返回值是转换后的字符(以ASCII码值返回)。
- 使用示例
- 以下是一个C++ 示例代码:
- 功能概述
#include <iostream> #include <cctype> using namespace std; int main() { char ch1 = 'A'; char ch2 = 'a'; char ch3 = '5'; char upper_ch1 = toupper(ch1); char upper_ch2 = toupper(ch2); char upper_ch3 = toupper(ch3); cout << "将 'A' 转换为大写字母(本身就是大写,不变): " << upper_ch1 << endl; cout << "将 'a' 转换为大写字母: " << upper_ch2 << endl; cout << "将 '5' 转换为大写字母(非小写字母,不变): " << upper_ch3 << endl; return 0; }- 在这个示例中,`toupper(ch2)`会将小写字母`a`(ASCII码值为97)转换为大写字母`A`(ASCII码值为65)。对于已经是大写字母的`ch1`和非字母的`ch3`,函数返回原始字符。这些函数在处理文本相关的操作中非常有用,比如在字符串比较、格式化文本等场景下,需要统一字母的大小写时,就可以使用
tolower和toupper函数。它们主要是基于ASCII码表的规则来进行转换,大写字母和小写字母在ASCII码表中的值有固定的差值,这使得函数能够有效地进行转换操作。 -
@ 2024-12-15 15:35:31
在C和C++编程语言中,
isalpha(ch)、isupper(ch)和islower(ch)这三个函数都是用于字符类型判断的,它们通常位于<cctype>头文件(C语言中是<ctype.h>头文件,C++兼容C语言的这种使用方式)中,以下是对它们各自功能及用法的详细介绍:isalpha(ch)- 函数功能:
用于判定字符
ch是否属于字母范畴。这里所说的字母包含了英文字母表中的大写字母(从A到Z)以及小写字母(从a到z)。 - 返回值:
如果
ch确实是一个字母(大写或者小写均可),函数会返回一个非零值(在逻辑判断中可视为true,表示满足“是字母”这个条件);反之,如果ch是数字、标点符号、空格或者其他非字母类型的字符,函数就返回0(相当于逻辑上的false,意味着该字符不符合“是字母”的判定条件)。
例如:
#include <iostream> #include <cctype> using namespace std; int main() { char ch1 = 'A'; char ch2 = '8'; cout << "isalpha('A')返回值: " << isalpha(ch1) << endl; // 预期返回非零值,因为 'A' 是字母 cout << "isalpha('8')返回值: " << isalpha(ch2) << endl; // 预期返回0,因为 '8' 不是字母 return 0; }isupper(ch)- 函数功能:
此函数的作用是专门判断给定的字符
ch是否为大写字母,也就是检查字符是否落在A到Z的范围之内。 - 返回值:
当
ch是大写字母时,函数返回非零值(等同于true,表明该字符满足“是大写字母”的条件);而当ch为小写字母、数字、标点符号等非大写字母类型的字符时,函数返回0(相当于false,即不符合“是大写字母”的判定)。
例如:
#include <iostream> #include <cctype> using namespace std; int main() { char ch1 = 'B'; char ch2 = 'b'; cout << "isupper('B')返回值: " << isupper(ch1) << endl; // 预期返回非零值,因为 'B' 是大写字母 cout << "isupper('b')返回值: " << isupper(ch2) << endl; // 预期返回0,因为 'b' 不是大写字母 return 0; }islower(ch)- 函数功能:
和
isupper(ch)相对应,islower(ch)用于判断字符ch是否为小写字母,即判断其是否处于a到z的区间内。 - 返回值:
若
ch是小写字母,函数返回非零值(相当于true,意味着符合“是小写字母”的要求);要是ch是大写字母、数字、标点符号等非小写字母的字符,函数返回0(等同于false,表示不满足“是小写字母”的判定条件)。
例如:
#include <iostream> #include <cctype> using namespace std; int main() { char ch1 = 'c'; char ch2 = 'C'; cout << "islower('c')返回值: " << islower(ch1) << endl; // 预期返回非零值,因为 'c' 是小写字母 cout << "islower('C')返回值: " << islower(ch2) << endl; // 预期返回0,因为 'C' 不是小写字母 return 0; }在实际的编程场景中,这三个函数常常配合使用。比如在处理文本内容,需要对不同类型的字母分别进行不同操作时,可以先通过
isalpha(ch)判断字符是否为字母,若是字母再进一步借助isupper(ch)或者islower(ch)来区分是大写字母还是小写字母,进而执行相应的逻辑处理,像对不同大小写形式的字母进行转换、统计等操作都可能会用到这样的判断流程。 - 函数功能:
用于判定字符
-
@ 2024-12-11 21:06:43

-
@ 2024-12-7 21:43:12
-
功能
substr函数用于从一个字符串中提取子字符串。它根据指定的起始位置和长度,返回原始字符串中的一部分内容作为一个新的字符串。如果没有指定长度,它会提取从起始位置到字符串末尾的所有字符。
-
用法
- 基本语法
- 有两种常用的语法形式:
string substr(size_t pos = 0, size_t len = npos);,其中pos是子字符串的起始位置(默认是0,表示从字符串开头开始),len是要提取的子字符串的长度(默认是npos,表示提取从起始位置到字符串末尾的所有字符)。
- 有两种常用的语法形式:
- 提取从指定位置到末尾的子字符串
- 示例代码:
在这个例子中,#include <iostream> #include <string> int main() { std::string original = "Hello, World!"; std::string sub = original.substr(7); std::cout << "提取的子字符串为: " << sub << std::endl; return 0; }original.substr(7)表示从original字符串的第7个位置(下标为7,字符是W)开始提取子字符串,一直到字符串末尾,所以sub的值为World!。
- 示例代码:
- 提取指定长度的子字符串
- 示例代码:
这里,#include <iostream> #include <string> int main() { std::string original = "I love C++"; std::string sub = original.substr(2, 4); std::cout << "提取的子字符串为: " << sub << std::endl; return 0; }original.substr(2, 4)表示从original字符串的第2个位置(下标为2,字符是l)开始提取长度为4的子字符串,所以sub的值为love。
- 示例代码:
- 与其他函数结合使用
- 可以和
find函数等结合使用,实现更复杂的字符串处理操作。例如,先找到一个子字符串的位置,然后提取该位置之后的部分作为新的子字符串。 - 示例代码:
在这个例子中,首先使用#include <iostream> #include <string> int main() { std::string text = "The quick brown fox jumps over the lazy dog"; size_t position = text.find("fox"); if (position!= std::string::npos) { std::string sub = text.substr(position); std::cout << "提取的子字符串为: " << sub << std::endl; } return 0; }find函数找到"fox"在text中的位置。如果找到(position不等于string::npos),就使用substr函数从该位置开始提取子字符串,最后输出提取的子字符串。
- 可以和
- 基本语法
-
-
@ 2024-12-7 21:42:43
-
功能
find函数是string类中的一个重要成员函数,用于在字符串中查找指定的子字符串或字符。它会从字符串的起始位置开始查找,返回第一次找到目标的位置(这个位置是从0开始计数的下标)。如果在整个字符串中都没有找到目标,就返回string::npos,这是一个特殊的值,表示“未找到”。
-
用法
- 查找子字符串
- 基本语法:
size_t find(const string& str, size_t pos = 0) const;,其中str是要查找的子字符串,pos是开始查找的位置(默认是0,即从字符串开头查找)。 - 示例代码:
在这个例子中,#include <iostream> #include <string> int main() { std::string text = "I love programming in C++"; std::string sub = "programming"; size_t position = text.find(sub); if (position!= std::string::npos) { std::cout << "找到子字符串 '" << sub << "' 的位置是: " << position << std::endl; } else { std::cout << "未找到子字符串 '" << sub << "'" << std::endl; } return 0; }text.find(sub)会在text字符串中查找sub这个子字符串。如果找到了,就输出它的位置;如果没找到,就输出提示信息。
- 基本语法:
- 查找字符
- 基本语法:
size_t find(char c, size_t pos = 0) const;,其中c是要查找的字符,pos是开始查找的位置(默认是0)。 - 示例代码:
这里,#include <iostream> #include <string> int main() { std::string text = "Hello, World!"; char character = 'o'; size_t position = text.find(character); if (position!= std::string::npos) { std::cout << "找到字符 '" << character << "' 的位置是: " << position << std::endl; } else { std::cout << "未找到字符 '" << character << "'" << std::endl; } return 0; }text.find(character)会在text字符串中查找character这个字符。根据是否找到输出相应的信息。
- 基本语法:
- 指定查找起始位置
- 可以通过第二个参数来指定从字符串的哪个位置开始查找。这个功能在需要在字符串的某个特定区间内查找时很有用。
- 示例代码:
在这个例子中,首先找到#include <iostream> #include <string> int main() { std::string text = "abcabc"; std::string sub = "abc"; size_t firstPosition = text.find(sub); size_t secondPosition = text.find(sub, firstPosition + 1); std::cout << "第一次找到子字符串的位置是: " << firstPosition << std::endl; std::cout << "第二次找到子字符串的位置是: " << secondPosition << std::endl; return 0; }sub在text中的第一个位置firstPosition,然后通过text.find(sub, firstPosition + 1)从firstPosition + 1这个位置开始再次查找sub,得到第二个位置secondPosition。这样就可以在字符串中查找多个相同子字符串的不同位置了。
- 查找子字符串
-
-
@ 2024-12-7 21:42:12
- 长度获取相关成员函数
length和size- 功能:这两个函数的功能完全相同,用于返回字符串中字符的个数。
- 示例:
#include <iostream> #include <string> int main() { std::string str = "Hello, World!"; std::cout << "字符串长度为: " << str.length() << std::endl; std::cout << "字符串大小为: " << str.size() << std::endl; return 0; }
- 字符访问成员函数
operator[]和atoperator[]功能:可以通过下标访问字符串中的字符,类似于访问数组元素。不过,它不进行边界检查,如果下标超出范围,可能会导致程序出现未定义行为。- 示例:
#include <iostream> #include <string> int main() { std::string str = "abc"; char c = str[1]; std::cout << "通过operator[]访问的字符为: " << c << std::endl; return 0; } at功能:同样用于访问字符串中的字符,但它会进行边界检查。如果下标超出范围,会抛出std::out_of_range异常。- 示例:
#include <iostream> #include <string> int main() { std::string str = "abc"; try { char c = str.at(1); std::cout << "通过at访问的字符为: " << c << std::endl; } catch (std::out_of_range& e) { std::cerr << "出错啦: " << e.what() << std::endl; } return 0; }
- 字符串拼接成员函数
append和operator+append功能:用于在字符串的末尾添加另一个字符串、字符数组或单个字符等内容。- 示例:
#include <iostream> #include <string> int main() { std::string str1 = "Hello"; std::string str2 = " World"; str1.append(str2); std::cout << "拼接后的字符串为: " << str1 << std::endl; return 0; } operator+功能:可以使用+运算符来拼接两个字符串,返回一个新的拼接后的字符串。- 示例:
#include <iostream> #include <string> int main() { std::string str1 = "Good"; std::string str2 = " morning"; std::string str3 = str1 + str2; std::cout << "拼接后的字符串为: " << str3 << std::endl; return 0; }
- 字符串比较成员函数
compare和比较运算符(==、<等)compare功能:用于比较两个字符串。它返回一个整数值,小于返回负数,等于返回0,大于返回正数。- 示例:
#include <iostream> #include <string> int main() { std::string str1 = "abc"; std::string str2 = "abd"; int result = str1.compare(str2); if (result < 0) { std::cout << "str1小于str2" << std::endl; } else if (result == 0) { std::cout << "str1等于str2" << std::endl; } else { std::cout << "str1大于str2" << std::endl; } return 0; } - 比较运算符功能:可以直接使用
==、<、>等比较运算符来比较两个字符串,其内部实际上是调用了compare函数。 - 示例:
#include <iostream> #include <string> int main() { std::string str1 = "abc"; std::string str2 = "abc"; if (str1 == str2) { std::cout << "str1等于str2" << std::endl; } return 0; }
- 查找成员函数
find和rfindfind功能:用于在字符串中查找指定的子字符串或字符,返回第一次找到的位置(从0开始计数的下标),如果没找到则返回std::string::npos。- 示例:
#include <iostream> #include <string> int main() { std::string str = "Hello, World"; size_t position = str.find("World"); if (position!= std::string::npos) { std::cout << "找到子字符串的位置为: " << position << std::endl; } else { std::cout << "未找到子字符串" << std::endl; } return 0; } rfind功能:和find类似,但它是从字符串的末尾开始查找指定的子字符串或字符,返回最后一次找到的位置(从0开始计数的下标),没找到也返回std::string::npos。- 示例:
#include <iostream> #include <string> int main() { std::string str = "Hello, World"; size_t position = str.rfind("o"); if (position!= std::string::npos) { std::cout << "从末尾找到字符的位置为: " << position << std::endl; } else { std::cout << "未找到字符" << std::endl; } return 0; }
- 替换成员函数
replace- 功能:用于替换字符串中的一部分内容,可指定起始位置、长度和替换后的内容。
- 示例:
#include <iostream> #include <string> int main() { std::string str = "I like coffee"; str.replace(7, 6, "tea"); std::cout << "替换后的字符串为: " << str << std::endl; return 0; }
- 长度获取相关成员函数
- 1