C++ implementation of linkedlist