#include <iostream> #include <cassert> #include <algorithm> #include <vector> #include <deque> using namespace std; int main() { vector<int> vector1(20); for (int i = 0; i < 20; ++i) vector1[i] = i; vector<int>::iterator pos; for (pos=vector1.begin(); pos!=vector1.end(); ++pos) { cout << *pos << ' '; } return 0; }
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
16.2.vector subscript indexer | ||||
16.2.1. | Use indexer to add elements to a vector | |||
16.2.2. | Use indexer to reference elements in a vector | |||
16.2.3. | Loop thourgh all elements in a vector using < | |||
16.2.4. | Loop through all elements in a vector using operator [] instead of operator * | |||
16.2.5. | Converting to C-style strings. |