vector
原文地址:http://www.cnblogs.com/edisonfeng/archive/2011/08/30/2159041.html
vector<int> ages;
ages.reserve(80);//指定容量为80
cout<<"vector的容量为:"<<ages.capacity()<<endl;
//向容器中逐个添加元素
ages.push_back(100);
ages.push_back(200);
ages.push_back(300);
cout<<"vector的元素个数为:"<<ages.size()<<endl;
cout<<"第二个元素是:"<<ages[1]<<endl;
//遍历vector中的元素
for(vector<int>::iterator iter=ages.begin(); iter!=ages.end();iter++)
{
cout<<(*iter)<<endl;
}
cout<<(*ages.begin())<<endl;
system("pause");
return 0;
完