Begin with the ~stc++~ header and the ~std~ namespace.
#+begin_src cpp
#include <bits/stc++.h>
using namespace std;
#+end_src
Define the data structure that will represent a single element (node) in the linked list.
#+begin_src cpp
struct Node {
int data;
struct Node* next;
Node(int d) {
this->data = d;
this->next = NULL;
}
};
#+end_src
Initialize a new linked list, with an initial value of =0=.
#+begin_example
(0 ->)
#+end_example
To illustrate our example we will create a simple linked list with three distinct nodes. The first step is creating our root node.
#+begin_src cpp
Node* head = new Node(0);
#+end_src
We can then append new items through the ~next~ field, which is a pointer to the next item in the list. When this value is ~NULL~ we have reached the end of the list.