An example to illustrate Dynamic memory allocation and deallocation



#include <iostream.h>
#include <conio.h>
void main( )
{
int *ptr;
clrscr();
ptr = new int;
*ptr = 15;
cout<<”Value at pointer = “<< *ptr<<”\n”;
delete ptr;
getch();
}
Output :
Value at pointer = 15

0 comments: