Hey folks, just a quick question i can't seem to find the answer to. If i overwrite a container with a pointer in it, does the pointer and therefore the object it points to still exist, and would that be considered a bad handling of memory.
For instance. I have 2 vectors pointers to objects:
vector<DNA*> m_vPopulation2;
vector<DNA*> m_vParentPop2;
I know they are the same size, although would that matter?. And i want to make m_vPopulation2 = m_vParentPop2. Basicly i want all the elements inside population to become the elements inside ParentPop. Could i just write:
m_vPopulation2 = m_vParentPop2;
or would i have to loop through and transfer each pointer and then delete the origonal? Like this:
for(int i=0; i<m_vPopulation2.size(); i++)
{
delete m_vPopulation2[i];
m_vPopulation2[i] = m_vParentPop2[i];
delete m_vParentPop2[i];
}
or something similar?
Alternativly if there is a better way to do this and im being a tard please let me know.
Thx!