1.string.erase(pos,n)
其中pos为子字符串起始位置,n是要删除的字符串长度
#include<string>
#include<iostream>
using namespace std;
int main()
{
string a="ABCDEFGH";
a.erase(1,2);
cout<<a<<endl;
return 0;
}
2.string.erase(pos)
pos是子字符串起始位置,这里没有指定长度,默认删除起始位置之后的所有字符
3.string.erase(firset,last)
删除迭代器 [first, last) 区间的所有字符,特别注意这里的区间是左闭右开的
4.string.erase(firset)
如果没有指定last迭代器的话,只删除first迭代器位置处的单个字符