1234
//vector is a member variable vector.push_back(MyObject()); //storing the pointer to the object in the vector storePointer(&vector.at(0));
12345678910111213141516
#include <iostream> #include <vector> int main() { std::vector<int> vi; for (int i=1; i <= 10; ++i) { vi.push_back(i); std::clog << &vi.at(0) << '\n'; } std::clog << std::endl; }
0x550ec8 0x550ee8 0x550ef8 0x550ef8 0x550f10 0x550f10 0x550f10 0x550f10 0x550f38 0x550f38
my_vector.data()
&my_vector.at(0)