void SinglyLinkedList::removeBike(int c)
{
Node* current = head;
for(int i = 0; i < c; i++){ // traverse to desired node
current = current -> next;
}
if(current -> next != NULL && current -> prev != NULL){
current -> prev -> next = current -> next;
current -> next -> prev = current -> prev;
delete current; //delete node
}
else if(current -> next == NULL){
current -> prev -> next = current;
delete current;
}
else if(current -> prev == NULL){
current -> next -> prev = current;
delete current;
}
else
cout << "How did you make it this far?";
}
I'm fairly certain I'm not understanding something here, but research hasn't helped so far.
Logically it makes sense to me but I feel like this is too simple to work, which it isn't.
edited: updated the code minus input check and it breaks on me when I input any int. also I should probably rename the class to doubly linked list... just noticed that
for(int i = 0; i < c; i++){should befor(int i = 0; i < c || current != NULL; i++){.