I use a simple code:
std::vector < float > arr = { 3.42f, 6.45f, 53.43f };
float *elemPtr;
elemPtr = &arr[ 0 ];
std::cout << "elemPtr = " << *elemPtr << std::endl;
arr.push_back( 7.0f );
std::cout << "elemPtr = " << *elemPtr << std::endl;
And that code produces me following output:
elemPtr = 3.42
elemPtr = -6.25982e+18
Why does it happening after push_back? I didn't remove the first element of the vector. Why does it works like this?
I use Clang compiler (Xcode).