I have a method that when given a command, removed all pointers of objects stored in a vector. These pointers were all created on the heap using new
command. This is what I have for the method and I am getting segmentation fault 11 error.
else if (command == "Clear") {
size_t allGrades = grades.size();
for (size_t i = 0; i < allGrades; ++i) {
grades[0] = nullptr;
delete grades[0];
}
}
where grades
is the vector of pointers that have been allocated on the heap. How would I fix this?
Aucun commentaire:
Enregistrer un commentaire