The Memory is allocated in two ways either in Static and either in Dynamic. In Static Memory Allocation the Size of Memory may be Fixed and pre-defined but the Limitation of Static Memory is that when a user Stores Large Amount of data or Large Number of Elements are Increased instead the Declarable size of Numbers So The Concept of Dynamic Memory Allocation is used When we doesn’t know about the actual size or when we doesn’t known about the Number of elements For this purpose we uses Dynamic Memory Allocation.
There are Four different Memory Allocation Functions those are as Follows:-
1) New :- This Function Allocates a Specified Number of bytes in a Memory. The Starting Address of Memory will be Returned when Address if Function Successfully Locates the Required number of bytes in Memory. But Always Remember that For Creating or Allocating the New Memory We must have to use the Pointer variable because the Pointer variable will Store the Address of Allocated Memory.
2) Delete :- This Function is used for Deleting that Memory which is Consumed by the New Operator. We must have to specify the Name of Pointer variable because Memory is always consumed by the Pointer variable. When we specify the Name of Pointer variable then this will Automatically Detect the Address of Variable.