```
vector<int> v;
v.push_back(0); //you have to do this
//v[0] = 0;     //this gives you an error
v[0] = 1000000; //but now you can set it

```

So, how come the first time you initialize a vector, you have to push\_back, and after that you can just set it? For a primitive type, say int, you can do int i = 0; for initialization.