void insert ( iterator p, InputIterator first, InputIterator last );
//The current string content is extended by inserting some additional content at a specific location within the string content (this position is determined by either pos1 or p, depending on the function version used).
string&erase( size_t pos = 0, size_t n = npos );
iterator erase( iterator position );
iterator erase( iterator first, iterator last );
//Erases a part of the string content, shortening the length of the string.
//Replaces a section of the current string by some other content determined by the arguments passed.
void swap (string& str );
//Swaps the contents of the string with those of object str, such that after the call to this member function, the contents of this string are those which were in str before the call, and the contents of str are those which were in this string.
#include <iostream>
#include <string>
using namespace std;
int
main(void)
{
string name ("Sam");
string family ("Andy");
name +="Y.";
name += family;
name +='\n';
cout << name << endl;
string str;
string str2 ="Writing ";
string str3 ="print 10 and then 5 more";
str.append(str2);
str.append(str3, 6, 3);
str.append("dots are cool", 5);
str.append("here: ");
str.append(10,'.');
str.append(str3.begin()+8, str3.end());
str.append<int>(5,0x2E);
cout << str << endl;
string s ("Hello");
s.push_back('C');
cout << s << endl;
string t;
string t1 ="World";
t.assign(t1);
cout << t << endl;
t.assign(t1, 2, 2);
cout << t << endl;
t.assign("how are you", 8);
cout << t << endl;
t.assign("fine");
cout << t << endl;
t.assign(10,'*');
cout << t << endl;
t.assign<int>(10,0x2D);
cout << t << endl;
t.assign(t1.begin()+2, t1.end()-1);
cout << t << endl;
string r="to be question";
string r2="the ";
string r3="or not to be";
string::iterator it;
// used in the same order as described above:
r.insert(6,r2);//to be (the )question
r.insert(6,r3,3,4);//to be (not)the question
r.insert(10,"that is cool",8);//to be not(that is)the question
r.insert(10,"to be ");//to be not(to be )that is the question
r.insert(15,1,':');//to be notto be(:) that is the question
it = r.insert(r.begin()+5,',');//to be(,)notto be: that is the question
r.insert (r.end(),3,'.');//to be,notto be: that is the question(...)