16.1.3 使用字符串

// 1.比较字符串
重载了 <; <=; ==; >=; >; !=; 六个关系运算符用于比较string字符串,并且每个关系运算符都以三种方式重载,使之还满足string、C-风格字符串之间的比较。
// 2.返回字符串长度
size()   // 成员函数:来自较早版本的string
length()    // 成员函数:提供STL兼容性
// 3.搜索字符或子字符串
size_type find(const & str, size_type pos = 0) const   // 返回首字符索引,没找到str时返回string::npos 
size_type find(const char * s, sie_type pos = 0) const    // 返回首字符索引,没找到*s时返回string::npos
size_type find(const char * s, size_type pos = 0, siez_type n)   // 返回首字符索引,没找到*s的前n个字符组成的子字符串时返回string::npos 
size_type find(char ch, size_type pos = 0) const    // 返回字符ch首次出现的索引,否则返回string::npos
--------------------------------------------------------------------------------------
string库提供的其它成员方法(重载函数特征标与find相同):
// 4.查找字符或子字符串最后一次出现的位置
rfind(...)
// 5.在字符串中查找参数中任何一个字符首次出现的位置
find_first_of(...)
// 6.在字符串中查找参数中任何一个字符最后出现的位置
find_last_of(...)
// 7.在字符串中查找第一个不包含在参数中的字符
find_first_not_of(...)
// 8.在字符串中查找最后一个不包含在参数中的字符
find_last_not_of(...)
原文地址:https://www.cnblogs.com/suui90/p/13544926.html