Vectors don't store their elements in contiguous memory - it wouldn't be possible for them to be dynamically resized if that was the case.
For instance, if you allocate two vectors of length 10 at the start of your program, chances are they'll be stuck next to each other in memory. Later on, you decide you want to add another 100 elements to the first vector. That space isn't available next to the vector, so what's it do? It tries to find space elsewhere in memory and then sets up a pointer for the behind-the-scenes vector math so that when the iterator goes from 10 to 11, it knows to jump to the new segment of memory.
__________________
Eat antimatter, Posleen-boy!
|