If the list looks like this:
***************
head->*Data: XXX *
*Prev: NULL * ***************
*Next: --------> * Data: YYY *
*************** <----Prev: * ***************
* Next: --------> * Data: ZZZ *
***************<------Prev: *
* Next: NULL *
***************
Now: Add the new item
head = new dnode<dataType> (AAA,NULL,head);
***************
head->*Data: AAA *
*Prev: NULL * ***************
*Next: --------> * Data: XXX *
*************** * Prev: NULL * ***************
* Next: --------> * Data: YYY *
***************<------Prev: * ***************
* Next: --------> * Data: ZZZ *
***************<------Prev: *
* Next: NULL *
***************
Notice the second item in the chain. The Prev member is still NULL.
So to add the link from the second item back to the head.
head->next->prev=head;
***************
head->*Data: AAA *
*Prev: NULL * ***************
*Next: --------> * Data: XXX *
***************<-----Prev: * ***************
* Next: --------> * Data: YYY *
***************<------Prev: * ***************
* Next: --------> * Data: ZZZ *
***************<------Prev: *
* Next: NULL *
***************
So you can think of the line:
head->next->prev=head;
// This is equivelant too:
oldHead = head->next;
oldHead->prev = head;