//string 本质上是一个类,类内维护一个char*
//不用担心复制越界和取值越界
#include<iostream>
#include<string>
using namespace std;
int main(){
//字符串构造方式
string str1;
const char* s="hello";
string str2(s);
string str3(str2);
string str4(10,'a');
//string赋值操作
//=或者assign
str1=str2;
str3="world";
str4='c';
str4.assign("helloccc");
str4.assign("helloccc",5);//把前5个字符赋值给str4
str4.assign(str3);
str4.assign(10,'w');
//string容器字符串拼接
str4=str4+"hello word";//+=号重载
str4+='v';
str4+=str3;
cout<<str4;
//append函数实现字符串拼接
str1.append(str4,10,2);
str1.append("白痴",2,2);//从第二个开始往后拼接两个到str1
cout<<endl<<str1;
return 0;
}