# Include <iostream> </P> <p> template <typename T> <br/> class double_linked <br/>{< br/> struct node <br/> {< br/> T data; <br/> node * Prev; <br/> node * Next; <br/> node (T, node * P, node * n): Data (t ), prev (P), next (n) {}< br/>}; <br/> node * head; <br/> node * tail; <br/> public: <br/> double_linked (): Head (null), tail (null) {}< br/> template <int n> <br/> double_linked (T (& ARR) [N]): Head (Nu LL), tail (null) <br/>{< br/> for (int I (0); I! = N; ++ I) <br/> push_back (ARR [I]); <br/>}</P> <p> bool empty () const {return (! Head |! Tail) ;}< br/> operator bool () const {return! Empty () ;}< br/> void push_back (t); <br/> void push_front (t); <br/> T pop_back (); <br/> T pop_front (); </P> <p> ~ Double_linked () <br/>{< br/> while (head) <br/>{< br/> node * temp (head ); <br/> head = head-> next; <br/> Delete temp; <br/>}< br/> }; </P> <p> template <typename T> <br/> void double_linked <t>: push_back (t data) <br/>{< br/> tail = new node (data, tail, null); <br/> If (tail-> PREV) <br/> tail-> Prev-> next = tail; </P> <p> If (empty () <br/> head = tail; <br/>}</P> <p> template <typename T> <br/> void double_linked <t >:: push_front (t data) <br/>{< br/> head = new node (data, null, head); <br/> If (Head-> next) <br/> head-> next-> Prev = head; </P> <p> If (empty () <br/> tail = head; <br/>}</P> <p> template <typename T> <br/> T double_linked <t >:: pop_back () <br/>{< br/> If (empty () <br/> throw ("double_linked: List empty"); <br/> node * temp (tail ); <br/> T data (tail-> data); <br/> tail = tail-> Prev; </P> <p> If (tail) <br/> tail-> next = NULL; <br/> else <br/> head = NULL; </P> <p> Delete temp; <br/> return data; <br/>}</P> <p> template <typename T> <br/> T double_linked <t >:: pop_front () <br/>{< br/> If (empty () <br/> throw ("double_linked: List empty"); <br/> node * temp (head ); <br/> T data (Head-> data); <br/> head = head-> next; </P> <p> If (head) <br/> head-> Prev = NULL; <br/> else <br/> tail = NULL; </P> <p> Delete temp; <br/> return data; <br/>}</P> <p> int main () <br/> {<br/> int arr [] = {4, 6, 8, 32, 19 }; <br/> double_linked <int> Dlist (ARR); <br/> Dlist. push_back (11); <br/> Dlist. push_front (100); <br/> while (Dlist) <br/> STD: cout <Dlist. pop_back () <"; <br/>}