To delete an object created with the new keyword from memory, the delete keyword can be used. For each object created with new there should be a corresponding deletion using delete. Otherwise, objects not deleted are sometimes left lingering in memory, hogging more and more resources. This is called a memory leak, which can be the cause of many errors. Consider the following code for the creation and deletion of an object in memory.
#include <iostream> int main() { int *Number = new int; *Number = 5; std::cout<<*Number; delete Number; return 0; }