Check out example codes for "delete in c++". It will help you in understanding the concepts better.

Code Example 1

// Delete pointer
int* ptr1 = new int;
delete ptr1;

// Delete array
int* array = new int[10];
delete[] array;

Code Example 2

#include<stdio.h> 
#include<stdlib.h> 
int main() 
{ 
    int x; 
    int *ptr1 = &x; 
    int *ptr2 = (int *)malloc(sizeof(int)); 
    int *ptr3 = new int; 
    int *ptr4 = NULL; 
  
    /* delete Should NOT be used like below because x is allocated  
        on stack frame */
    delete ptr1;   
  
    /* delete Should NOT be used like below because x is allocated  
        using malloc() */
    delete ptr2;   
  
    /* Correct uses of delete */
    delete ptr3; 
    delete ptr4; 
  
    getchar(); 
    return 0; 
}

Learn ReactJs, React Native from akashmittal.com