I finally have some time, thanks to COVID-19, to go back and cement sections into my brain. This was an old project of mine where I had points taken off for my delete item not working.
Could someone walk me through what's wrong with this?
Thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void cdCollection::delete_item(string q){
Node *deleteTemp, *clear;
if(head == NULL){
return;
}
elseif(head -> name == q){
clear = head;
head = head -> next;
delete clear;
}
}
Your code will only work if the first item in the list matches string q. What if the matching item is in the middle of the list? What if it's at the end?