Lieven wrote:
Consider:
std::vector<int> vec(100);
vector<int>::iterator it(vec.begin());
for(int i(0); i < 10000000; i++){
vec.push_back(rand());
}
It is possible that vec get's reallocated. My question is: to what will it
point? Does it get reallocated to?
In almost all implications (but of course not guaranted by the standard)
it will continue pointing to whatever bit of memory the original vector
was allocated to, but now that memory won't be owned by the vector any more.
Offically, reading or writing to it is undefined. Unoffically, you are
likely to find that you think you can get away with reading from it for
some time after reallocation, as most systems won't bother wiping the
memory the vector was in until something else is put there. However of
course DO NOT DO IT! Because it's likely to break in all kinds of
interesting ways and be a very difficult bug to track down.
Chris