C++ new operator example: C++ code using new operator to dynamically allocate memory on heap.
C++ programming code
If you allocate memory using new then it will remain allocated until the program exits unless you explicitly deallocate with delete. Above program contains only one function so memory will be deallocated after program exits but we have specifically used delete as it is a good programming practice to deallocate memory which is not required further in the program.