标签:style blog color 使用 os io strong for
初始化:
1. 默认构造:
vector<int> vint;
2. 用包含10个元素的数组初始化:
vector<int> vint(ia, ia+10);
算法:
1. vint.push_back(i);
2. vint.size();
3. vint[i];
代码:
1 #include <vector> 2 #include <iostream> 3 using namespace std; 4 5 int ia[] = {123,1,32,53,23,21,45,56,54,223, 669,654}; 6 7 int main() { 8 //initialize 9 vector<int> vint1; 10 vector<int> vint2(ia, ia+10); 11 12 //push_back() 13 for(int i = 0; i <=6; ++i) 14 vint1.push_back(i); 15 16 //size() 17 cout << "The size of vint1 is: " << vint1.size() << endl; 18 19 //[] operator 20 for(int i = 0; i < vint2.size(); i++) 21 cout << vint2[i] << endl; 22 23 return 0; 24 }
【STL】- vector的使用,布布扣,bubuko.com
标签:style blog color 使用 os io strong for
原文地址:http://www.cnblogs.com/dracohan/p/3895305.html