Nodes
The basic unit of storage for a linked list is a node. A node stores data and one or more pointers to other nodes. At its most basic, a linked list node consists of data plus a pointer to the next node in the linked list.
The following shows how to declare a simple node for storing doubles.
To create linked lists that hold other data types the data portion of a node would need to be a different data types.
Other data structures such as trees, also store data in nodes. If you wish to create a library of data structures and want to avoid naming conflicts, you can nest the Node declaration within your linked list class. This also allows you to use a struct of a node and not worry about access permissions
Last updated