replace有很多重载形式(解释一下你这里参数的意思):
第一个参数是a的起始位置,第二个参数是结束位置,第三个参数是被替换的字符个数,第4个是用来替换的字符。
basic_string::replace
basic_string& replace(size_type p0, size_type n0,
const E *s);
basic_string& replace(size_type p0, size_type n0,
const E *s, size_type n);
basic_string& replace(size_type p0, size_type n0,
const basic_string& str);
basic_string& replace(size_type p0, size_type n0,
const basic_string& str, size_type pos, size_type n);
basic_string& replace(size_type p0, size_type n0,
size_type n, E c);
basic_string& replace(iterator first0, iterator last0,
const E *s);
basic_string& replace(iterator first0, iterator last0,
const E *s, size_type n);
basic_string& replace(iterator first0, iterator last0,
const basic_string& str);
basic_string& replace(iterator first0, iterator last0,
size_type n, E c);
basic_string& replace(iterator first0, iterator last0,
const_iterator first, const_iterator last);
Each member function replaces up to n0 elements of the controlled sequence beginning with position p0, or the elements of the controlled sequence beginning with the one pointed to by first, up to but not including last. The replacement is the operand sequence specified by the remaining operands. The function then returns *this.
In this implementation, if a translator does not support member template functions, the template:
template<class InIt>
basic_string& replace(iterator first0, iterator last0,
InIt first, InIt last);
is replaced by:
basic_string& replace(iterator first0, iterator last0,
const_iterator first, const_iterator last);
[此贴子已经被作者于2006-10-15 19:54:43编辑过]