C++ LinkedList implementation using inheritance