C++ implementation of doubly linked list