Here is my doubly linked list:
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); }; Add item:
void List::Add(int x) { Num *temp = new Num; temp->next = NULL; temp->number = x; if(head != NULL) { temp->prev = tail; tail->next = temp; tail= temp; } else { temp->prev = NULL; head = tail = temp; } } And deletion:
bool List::Remove(int idx) { Num *current = head; Num *temp = NULL; int i = 0; while(current->next != NULL) { if(i != idx) { current = current->next; i++; } else { if (idx == 0) { temp = head; head = current; } else { temp = current->prev; current->prev = temp->prev; current->prev->next = current; } delete temp; return true; } } return false; } How to make a queue of it? (you can make the inheritance of the queue from the list)