#include #include // to define NULL using namespace std; class D{ //a dumb double linked list. public: D(char c, D* p){chr=c; prev=p; next=NULL; } char chr; // data for list D* prev; // previous node in list D* next; // next node in list };// class D main() { D* t; D* h; // t for tail and h for head of list. // construct a list with one element t = h = new D('a', NULL); // add next element to h and update t to point at it. t = h->next = new D('b', t); // add thrid element to h and update t to point at it. t = h->next->next = new D('c', t); // add fourth element to h and update t to point at it. t = h->next->next->next = new D('d', t); //test out what we've got -- from head to tail cout << h->chr << h->next->chr << h->next->next->chr << h->next->next->next->chr << endl; //test out what we've got -- from back to front cout << t->chr << t->prev->chr << t->prev->prev->chr << t->prev->prev->prev->chr << endl; return 0; }