how to create a linked list in cpp code example

Example 1: cpp linked list

struct Node {
  int data;
  struct Node *next;
};

Example 2: cpp linked list

#include <bits/stdc++.h>

using namespace std;
int main() {

    class Node {
        public:
            int data;
        Node * next;
    };
}

Example 3: linked list class c++ basic implementation

template<typename T>
class list {
  public:

    struct node {
        T value;
        node* next;
    };

    list() : hd(nullptr), tl(nullptr) {}

    node* head() { return hd; }
    node* tail() { return tl; }

    void insert(node* prior, T value);

    node* at(int i);    

    void erase(node* prior);
    void clear();

    void push_back(T value);
    void pop_back();

    void push_front(T value);
    void pop_front();

    int size();    

  private:
    node* hd, tl;
}