title: Insert a node in a doubly linked list after a given node
body: <p>I have a function that inserts an integer after a node in a doubly linked list.  It compiles just fine.  However, when I run it with a test case using a doubly linked list called DLL populated by 2 4 6 8 and try calling the function to insert 5 after 4, nothing happens to the linked list, so this is wrong. I just don't know why.</p>
  
  <pre><code>void DoublyLinkedList::insertAfter(const DListNode &amp;p, int newobj) {    
    DListNode *newNode = new DListNode(newobj);
    DListNode *node = header.next;
    while(node != &amp;p) {
      node = node-&gt;next;
    }
    node = node-&gt;next;
    node-&gt;next-&gt;prev = newNode;   
  }
  </code></pre>