i am always getting segmentation fault

  allocation, c++, memory, segmentation-fault

i am always getting 10861 segmentation fault (core dumped) in c++ sorry i came from java
it always says that head -> next how to allocate memory to that

#include <iostream>
using namespace std;

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

class lisp
{
public:
  Node *head;
  void create(int d)
  {
    this->head->data = d;
    cout << head->data;
  }
  void insert(int d)
  {
    Node *n = head;
    Node *add;
    add->data = d;
    cout << head -> next << endl; 
  }
};

int main()
{
  lisp test;
  test.create(0);
  test.insert(1);
  test.insert(2);
  return 0;
}

Source: Windows Questions C++

LEAVE A COMMENT