Here I have a vector containing a list of what it thinks are prime numbers, however, some of the later values are divisiable by some values that appear earlier in the list.
To amend this, I tried to iterate around my vector v, and delete the value if it could be divided by another in the vector with no remainder.
However I keep getting this error ("No matching member function to call for erase") and can't think of any other way to delete the value that my iterator points at through this loop. Any suggestions?
for (vector<int>::iterator it2 = v.begin();it2 != v.end(); ++it2){
for (vector<int>::iterator it3 = v.begin();it3 != v.end(); ++it3){
if (*it3%*it2 == 0){
v.erase (*it2);
}
}
}
Aucun commentaire:
Enregistrer un commentaire