Advertisement
shabbyheart

Link list

Apr 20th, 2019
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class Node{
  5. public:
  6.     int data;
  7.     Node* next;
  8. };
  9.  
  10. class LinkedList{
  11.     Node* head;
  12. public:
  13.     LinkedList(){
  14.        head = NULL;
  15.     }
  16.     void Insert(int data){
  17.         Node* NewNode = new Node();
  18.         NewNode -> data = data;
  19.         NewNode -> next = NULL;
  20.  
  21.         head = NewNode;
  22.  
  23.     }
  24.  
  25.     void Delete(){
  26.         Node* Temp = head;
  27.         head = Temp -> next;
  28.         delete(Temp);
  29.     }
  30. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement