my vector has now moved elsewhere in memory right? So is the pointer p still valid? I now that iterators become invalid, but what about pointers to the vector itself? If not, why? Hasn't the vector moved in memory?
my vector has now moved elsewhere in memory right?
The vector itself hasn't. Its underlying array, starting at &myVec[0], could potentially move if the resize cannot get a contiguous chunk of memory at its current location.
So is the pointer p still valid?
&myVec is still valid; &myVec[0] may have changed.
but what about pointers to the vector itself? If not, why? Hasn't the vector moved in memory?