连接:http://blog.csdn.net/qcontriver/article/details/36179083
//一、直接构造
string one("Lottery Winner");
cout << one << endl;
//二、20个元素的string对象,每个元素初始为$
string two(20,'$');
cout << two << endl;
//三、复制构造函数
string three(one);
cout << three << endl;
//重载 +=
one += " Oops!";
cout << one << endl;
//重载 + =
two = "Sorry! That was ";
three[0] = 'p';
string four;
four = two + three;
cout << four << endl;
//四、将five初始化为alls的前20个字符,即使超过了alls结尾也没事
char alls[] = "All`s well that ends well";
string five(alls, 20);
cout << five << endl;
//五、将six初始化alls的[6,10)之间的字符,6包含,10不包含。注:这是下标
string six(alls + 6,alls + 10);
cout << six << ", ";
//六、同six
string seven(&five[6], &five[10]);
cout << seven << "...\n";
//七、将eight初始化为four中,从位置7(下标)开始的16个字符,或者结尾;
string eight(four, 7, 16);
cout << eight << " in motion!" << endl;