This code is printing 30 only what's wrong on this?
I've followed this tutorial https://www.codementor.io/codementorteam/a-comprehensive-guide-to-implementation-of-singly-linked-list-using-c_plus_plus-ondlm5azr
I've no idea on how this printing only 30? Anything wrong on this code?
#include <iostream>
using namespace std;
struct node {
    int data;
    node *next;
};
class LinkedList {
    private:
        node *head, *tail;
    public:
        LinkedList() {
            head = NULL;
            tail = NULL;
        }
        // For adding nodes
        void addNode(int value) {
            node *tmp = new node;
            tmp->data = value;
            tmp->next = NULL;
            if(head == tail) {
                head = tmp;
                tail = tmp;
                tmp = NULL;
            } else {
                tail->next = tmp;
                tail = tail->next;
            }
        }
        // For displaying nodes
        void display() {
            node *tmp = head;
            while(tmp != NULL) {
                cout << tmp->data << endl;
                tmp = tmp->next;
            }
        }
};
int main()
{
    LinkedList a;
    // For adding nodes
    a.addNode(10);
    a.addNode(20);
    a.addNode(30);
    // For displaying nodes
    a.display();
    return 0;
}
 
     
     
    