Code has been added to clipboard!

Adding Values and Pointers to Nodes in C++

Example
#include <cstddef>

using namespace std;

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

int main() {
    Node * head = NULL;
    Node * second = NULL;
    Node * third = NULL;

    head = new Node();
    second = new Node();
    third = new Node();

    head->data = 1;
    head->next = second;

    second-> data = 2;
    second-> next = third;

    third-> data = 3;
    third-> next = NULL;
}