A linked list can be defined as either
- The empty list (NULL)
- A node consisting of an element and a pointer to the next list.
The front of a list is commonly called its head, and the rest of the list is commonly called its tail (think of tadpoles, not dogs):
struct ListNode { int value; ListNode * next; ListNode(int value) { this->value = value; } }; class LinkedList { public: LinkedList(); ~LinkedList(); // Destructor: ignore for now bool isEmpty(); // is the list empty? int length(); // returns the list length // Retrieves an item from the given position int valueAt(int position); // Inserts an item into the list at the given position void insert(int value, int position); // Removes the item at the given position from the list void removeAt(int position); private: ListNode * head; };