#include using namespace std; template class Node { friend class LinkedList; private: Node * next; Node * prev; T data; public: Node(); }; template Node::Node() { next = NULL; prev = NULL; } template class LinkedList { private: Node * head; int position; public: LinkedList(); void print() const; void remove(int position); void insert(T x); }; template LinkedList::LinkedList() { head = NULL; position = 0; } template void LinkedList::print() { Node *tmp; tmp = head; while(tmp) { cout << "you have a " << (tmp->data).get_name() << " in slot " << position << endl; tmp = tmp -> next; } } template void LinkedList::remove(int position) { Node * tmp; Node * tmp2; Node * tmp3; tmp = head; int count = 1; while(tmp) { if(count == position) { if(position == 1) { head = tmp -> next; break; } else if(position > 1) { if(!tmp->next) { tmp->prev->next = NULL; } else { tmp2 = tmp->prev; tmp3 = tmp->next; tmp2->next = tmp3; tmp3->prev = temp2; break; } } else { break; } } tmp = tmp->next; count++; } } template void LinkedList::insert(T x) { Node * tmp = head; Node * new_node = new Node; new_node -> data = x; if(!head) { head = new_node; position = 1; } else { while(tmp->next != NULL) { position++; tmp = tmp->next; } new_node = tmp -> next; position ++; } }