previous | start | next

## Implementing Linked Lists (The Classes for Lists, Nodes, and Iterators)

- We will start with a linked list of strings.
- A linked list stores each value in a separate object called a node.

  >     class Node
  >     {
  >     public:
  >        Node(string s);
  >     private:
  >        string data;
  >        Node* previous;
  >        Node* next;
  >     friend class List;
  >     friend class Iterator;
  >     };

- The `friend` declarations indicate the `List` and `Iterator` member functions are allowed to inspect and modify the data members of the `Node` class.
- A class should not grant friendship to another class lightly, because it breaks the privacy protection.

previous | start | next