I have a loop
for(aI = antiviral_data.begin(); aI != antiviral_data.end();)
{
for(vI = viral_data.begin(); vI != viral_data.end();)
{
if((*aI)->x == (*vI)->x && (*aI)->y == (*vI)->y)
{
vI = viral_data.erase(vI);
aI = antiviral_data.erase(aI);
}
else
{
vI++;
aI++;
}
}
}
But when ever antiviral_data contains an item, I get an error "vector iterator not dereferencable." Why am I geting this error and where am I dereferencing an invalid iterator?
NB: So far th error only occurs when the if() statement is false. I don't know what happens if the if() statement is true.