string::erase
下面代码会输出什么?
std::string str = "hello";str.erase(0, 3);cout << str << endl;
erase:用于从字符串中删除一部分字符串,返回修改后的字符串引用
函数签名:
basic_string& erase(size_type pos = 0, size_type count = npos);
pos:起始位置,从哪里开始删除
npos:要删除字符串的数量
下面代码会输出什么?
std::string str = "hello";str.erase(0, 3);cout << str << endl;
erase:用于从字符串中删除一部分字符串,返回修改后的字符串引用
函数签名:
basic_string& erase(size_type pos = 0, size_type count = npos);
pos:起始位置,从哪里开始删除
npos:要删除字符串的数量