Upon successful deletion, it should return true, but for some reason it always returns a fall. Here is the class:
struct Num { int number; bool ring; Num *next, *prev; }; class List { protected : Num *head, *tail; public : List():head(NULL),tail(NULL){} ~List(); int genNum(); void Add(int x); bool Remove(int i); }; And my attempt to redo the deletion:
bool List::Remove(int idx) { Num *current = head; Num *temp = nullptr; int i = 0; while(current->next != NULL) { if(i != idx) { current = current->next; i++; } else { temp = current->prev; current->prev = current->next; current->next->prev = temp; return true; } } return false; }