#include <iostream>
#include <string>
// using string constructors

int main()
{
    using namespace std;
    string one("Lottery Winner!");     
    cout << one << endl;               // 
    string two(20, '$');               // two初始化为由20个字符串组成
    cout << two << endl;
    string three(one);                 // 
    cout << three << endl;
    one += " Oops!";                   // overloaded +=
    cout << one << endl;
    two = "Sorry! That was ";
    three[0] = 'P';
    string four;                       // ctor #4
    four = two + three;                // overloaded +, =
    cout << four << endl;
    char alls[] = "All's well that ends well";
    string five(alls,20);              // 输出前20个字符
    cout << five << "!\n";
    string six(alls+6, alls + 10);  // 数组名相当于指针,指向第一个元素地址,等同于six(alls,6,10)
    cout << six  << ", ";//输出第7和第11地址之间的元素
    string seven(&five[6], &five[10]); //等同于seven(alls+6, alls + 10)
    cout << seven << "...\n";
    string eight(four, 7, 16);         // ctor #7
    cout << eight << " in motion!" << endl;
    // std::cin.get();
    return 0; 
}