Statements such as vec.push_back(42);
are only allowed inside of functions. For example,
#include <iostream>
#include <vector>
int main()
{
using namespace std;
vector<int> vec;
vec.push_back(10);
vec.push_back(5);
vec.push_back(1);
vector<int>::iterator itr1 = vec.begin();
vector<int>::iterator itr2 = vec.end();
for(vector<int>::iterator itr = itr1; itr != itr2; itr++){
cout << *itr << endl;
}
}