STL的六大组件:
string
// string constructor
#include <iostream>
#include <string>
using namespace std;
int main()
{// 构造std::string s0("Initial string");std::string s1; //nullptrstd::string s2("A character sequence"); //A character sequence //from c-string std::string s3(10, 'x'); //xxxxxxxxxx //fill std::string s4(s0); //Initial string //copy std::string s5 = "hello"; //hello //from c-string // 三种遍历方式//1.下标+[] 也可此方法修改,因为是引用(&)for(int i=0; i<s2.size(); ++i){cout << s2[i] << endl;}
}