So I was given an assignment with starter code to implement a linked list (which I have done with an unsorted doubly linked list successfully) and in the starter code in the given header file there was a friend declaration that seems to have the goal of allowing me to print the linked list using the `cout` statement. This is the header file; note that I wrote everything in the private section.

```
#ifndef _LINKED_LIST_
#define _LINKED_LIST_

#include <ostream>

class LinkedList
{
public:
    LinkedList();
    ~LinkedList();

    void add(char ch);
    bool find(char ch);
    bool del(char ch);

    friend std::ostream& operator<<(std::ostream& out, LinkedList& list);

private:
    struct node
    {
        char data;
        node * next;
        node * prev;
    };
    node * head, * tail;
};

#endif // _LINKED_LIST_

```

In `main`, which was also part of the starter code, the teacher wrote `cout << list;` which leads me to believe the goal of the friend statement in the header file was to allow list to be printed to the console easily. Normally I wouldn't care but if I don't comment out the `cout << list;` statements then the linker gives me the following error for every instance of `cout << list;`

```
app.o: In function 'main':
[code directory]/app.cpp:[line the statement is on]: undefined reference to
'operator<<(std::ostream&, LinkedList&)'

```

**My question is**, what does `friend std::ostream& operator<<(std::ostream& out, LinkedList& list)` mean and why does `cout << list;` cause this error? The code executes fine without the statements and since I'm using the instructor's makefile to assemble the assignment, I figure that isn't the issue.

app.cpp is as follows 

```
#include <iostream>
#include "linkedlist.h"

using namespace std;

void find(LinkedList& list, char ch)
{
    if (list.find(ch))
        cout << "found ";
    else
        cout << "did not find ";
    cout << ch << endl;
}

int main()
{
    LinkedList  list;

    list.add('x');
    list.add('y');
    list.add('z');
    cout << list;
    find(list, 'y');

    list.del('y');
    cout << list;
    find(list, 'y');

    list.del('x');
    cout << list;
    find(list, 'y');

    list.del('z');
    cout << list;
    find(list, 'y');

    return 0;
}

```