I have a vector of class objects. A function randomly choses two elements and return their addresses.
Now using these two elements, I want to generate two new objects of the same class and add them to the vector by using push_back.
Here is the address of the two parent elements:
No problem here. The first child object is then generated, and I use vector_pushback to add it to the end of the vector. The problem is, after the push_back command has been executed, it seems like the addresses of the parent objects change. Here is the state of debugger after push_back:
As you can see, the addresses obviously stay the same, but it seems like they point to garbage values after push_back. To my understanding, push_back adds an element at the end of the vector. Therefore I expect the address of the 2 elements to not change at all.
What's wrong?