cpp implementation of Linked List Cycle