c++ implementation of linked lists