Even this isn't always possible. The new operator Allows us to dynamically allocate objects. To use this, declare a pointer to the object type you want, then assign it the value of the new operation. If we change the value of the pointer, without saving it somewhere, we have lost the object. Allocating arrays with new .
Arrays are just pointers to some memory.
If we declare them statically, the memory is on the stack and it goes away when the function exits. If we declare them dynamically, the memory last until we get rid of it. For example, a sort program could take an unsorted list and return a pointer to a sorted list. The new operator creates an object that lives for the duration of the program. The object does not get destroyed as soon as you exit the function in which it was created.