Originally posted by Cela
>>well doing push_back(Plane()) works just fine so I don't see the point in resize
push_back() and resize() do different things. resize() tells the vector to allocate enough space for N items so that multiple calls to push_back() are more efficient. push_back() allocates more space if needed, but doesn't if not needed, and then inserts a new item at the end.
To recap, resize() doesn't create N items, it only sets aside space for those items, push_back() actually adds them. So unless you really need exact performance, don't even worry about resize(), just use push_back().
I disagree... unless i'm missing something. Try this:
Code:
std::vector<int> intlist;
intlist.resize(8, 5);
for (std::vector<int>::iterator i = intlist.begin(); i < intlist.end(); ++i)
std::cout << *i;