I have a vector of objects of the Virus class. This vector is called 'Viruses.'
I have a deque of objects of the Host class. Each Host class object has a deque of pointers to Virus objects, i.e., deque< Virus * > currentInfections
Each Host object is randomly infected with different Virus objects. This means they go in the currentInfections deque.
I create a new Virus object called 'mutant' and add it to the Viruses vector, i.e., Viruses.push_back( mutant ).
Creating this mutant and pushing it back to the Viruses vector always destroys any Host objects' pointers to the first element in Viruses, without affecting the others or the first element itself. Instead of V1, V2, V3 in currentInfections, I get V2837188, V2, V3. The Viruses vector contains V1, V2, V3, mutant. And even more exciting, this always happens after the second mutant has been added to the Viruses vector, and it happens without constructing a pointer to the mutant. In other words, just creating these two mutants seems to screw up pointers to the first element in the vector. I don't even have to touch currentInfections for the error to appear.
I'm a doctoral student in biology and new to programming. No suggestion is too obvious.
I'm also desperate. Thanks for any help. Hope this is enough information for a diagnosis of some kind.