C++的STL(标准模板库)系列:容器——string容器

一.string容器

 

二.vector容器

1.初始化

注意:C++11才支持列表初始化:vector<int> test{1,2,3,4,5}

vector<int> test;            //默认初始化,空容器
 
vector<int> test(10);        //带参构造函数初始化10个值为0的元素
vector<int> test(10,1);      //带参构造函数初始化,10个值为1的元素
 
vector<int> test=test1;      //拷贝容器
vector<int> test(test1);
 
int a[5]={1,2,3,4,5};
vector<int> test(a,a+5);     //数组初始化容器
 
test.insert(test.begin(),test1.beigin().test1.end());    //插入容器
test.insert(test.begin(),a,a+7);

 

3.删除容器元素

vector.erase(itor);  //迭代器指向下一个容器元素

 

三.map容器

 

四.pair容器

 

五.list容器

 

六.set容器

posted @ 2019-07-02 09:44  言午丶  阅读(153)  评论(0编辑  收藏  举报