1
2int* ptr; // pointer declaration
3
4ptr = new int; // dynamically allocate an integer on heap
5delete ptr; // deletes integer from heap & frees memory
6ptr = nullptr; // always good to reset pointer
7
8ptr = new int[5]; // dynamically allocate integer array on heap with size 5
9delete[] ptr; // deletes integer array from heap & frees memory
10ptr = nullptr; // always good to reset pointer