#include<iostream>
using namespace std;
class Node{
    public:
    int data;
    Node* next;
};
class LinkedLIst{
    private:
    Node* head;
    public:
    
    LinkedLIst(){
        head=NULL;
    }
    
    void addNode(int data){
        Node* newNode = new Node();
        newNode->data = data;
        newNode->next = NULL;
        
        if(head == NULL){
            head = newNode;
        }
        else{
            Node* temp = head;
            while(temp!=NULL){
                temp = temp->next;
            }
            temp->next = newNode;// I think fault is here.
        }
    }
    
    void display(){
        Node* temp = head;
            while(temp!=NULL){
                cout<<temp->data<<" ";
                temp = temp->next;
            }
    }
    
    
    
};
int main(){
    
    LinkedLIst* lt = new LinkedLIst();
    lt->addNode(100);
    lt->addNode(200);
    lt->addNode(300);
    lt->display();
    return 0;
}
I am getting Segmentation fault(core dumbed) when i am running this code
 
     
    