Home › C++ Tutorial › C++ STL and vectors
C++ STL and vectors
Growable arrays.
The STL gives ready-made containers. A vector grows automatically: push_back, pop_back, size, at.
Example code
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> v = {3, 1, 2};
v.push_back(9);
for (int x : v) cout << x << " ";
cout << "size " << v.size() << endl;
return 0;
}