/* This program demonstrates dynamic memory allocation. * Dynamic Memory allocation is when we * a. Allocate Memory outside the function call stack in heap memory * b. We do this during runtime (after the program has started running) * * The allocated memory must be explicitly destroyed by the programmer * * To allocate: Use the "new" operator/ keyword * * To deallocate: Use the "delete" operator/keyword */ #include #include using namespace std; int main() { /* Dynamic memory * We declare a variable in dynamic (heap) space and then can ONLY access it * through a pointer * A variable in dynamic space is declared using the keyword "new" * Once we're done using the variable, it is cleared from memory using the "delete" keyword */ int *ptr; ptr = new int; cout<<"Enter a number: "; cin>> * ptr; cout<<"Value of dynamic integer variable created: "<< * ptr <