title: doubly linked list: value is not inserted at front
body: <p>Here is a DLinkedList Implementation, an element of int type is added to it using addFront(), but its not retrieved using front().. No Error is displayed. Don't know why ?? Here is complete implementation. Code is run on xCode4.5. </p>
  
  <pre><code>int main(int argc, const char * argv[])
  {
      DLinkedList listOne;
  
      if(listOne.empty()){
          cout&lt;&lt;"Empty";
      }
      const int num=23;
      listOne.addFront(num);
  
      //Here 0 is returned from front(), while it should be 23;
      cout&lt;&lt;listOne.front()&lt;&lt;endl;
  
      return 0;
  }
  
  //Node Defination
  class DNode {                   // doubly linked list node
  private:
      int elem;                   // node element value
      DNode* prev;                // previous node in list
      DNode* next;                // next node in list
      friend class DLinkedList;           // allow DLinkedList access
  };
  
  class DLinkedList {             // doubly linked list
  public:
      DLinkedList();              // constructor
      ~DLinkedList();             // destructor
      bool empty() const;             // is list empty?
      const int front() const;            // get front element
      const int back() const;         // get back element
      void addFront(const int e);     // add to front of list
      void addBack(const int e);      // add to back of list
      void removeFront();             // remove from front
      void removeBack();              // remove from back
  private:                    // local type definitions
      DNode* header;              // list sentinels
      DNode* trailer;
  protected:                  // local utilities
      void add(DNode* v, const int e);        // insert new node before v
      void remove(DNode* v);          // remove node v
  };
  
  void listReverse(DLinkedList&amp; L) {      // reverse a list
      DLinkedList T;              // temporary list
      while (!L.empty()) {            // reverse L into T
          int s = L.front();  L.removeFront();
          T.addFront(s);
      }
      while (!T.empty()) {            // copy T back to L
          int s = T.front();  T.removeFront();
          L.addBack(s);
      }
  }
  
  void DLinkedList::remove(DNode* v) {        // remove node v
      DNode* u = v-&gt;prev;             // predecessor
      DNode* w = v-&gt;next;             // successor
      u-&gt;next = w;                // unlink v from list
      w-&gt;prev = u;
      delete v;
  }
  
  void DLinkedList::removeFront()     // remove from font
  { remove(header-&gt;next); }
  
  void DLinkedList::removeBack()      // remove from back
  { remove(trailer-&gt;prev); }
  
  // insert new node before v
  void DLinkedList::add(DNode* v, const int e) {
      DNode* u = new DNode;  u-&gt;elem = e;     // create a new node for e
      std::cout&lt;&lt;u-&gt;elem&lt;&lt;std::endl;
      u-&gt;next = v;                // link u in between v
      u-&gt;prev = v-&gt;prev;              // ...and v-&gt;prev
      v-&gt;prev-&gt;next = v-&gt;prev = u;
  }
  
  void DLinkedList::addFront(const int e) // add to front of list
  {
      add(header-&gt;next, e);
  }
  
  void DLinkedList::addBack(const int e)  // add to back of list
  { add(trailer, e); }
  
  DLinkedList::~DLinkedList() {           // destructor
      while (!empty()) removeFront();     // remove all but sentinels
      delete header;              // remove the sentinels
      delete trailer;
  }
  
  DLinkedList::DLinkedList() {            // constructor
      header = new DNode;             // create sentinels
      trailer = new DNode;
      header-&gt;next = trailer;         // have them point to each other
      trailer-&gt;prev = header;
      std::cout&lt;&lt;"DLinkedListConstructor"&lt;&lt;std::endl;
  }
  
  bool DLinkedList::empty() const     // is list empty?
  { return (header-&gt;next == trailer); }
  
  const int DLinkedList::front() const    // get front element
  { return header-&gt;next-&gt;elem; }
  
  const int DLinkedList::back() const     // get back element
  { return trailer-&gt;prev-&gt;elem; }
  </code></pre>