This recipe will focus on the two main strategies C++ offers to allocate memory: automatic and dynamic memory allocation. A variable is automatic when its scope lasts for the duration of the block in which it is defined, and its allocation and deallocation are automatic (that is, not up to the developer). The variable is allocated on the stack.
A variable is dynamic if allocated in the dynamic portion of the memory (free store, which is often referred to as the heap), and the allocation and deallocation are up to the developer. Greater flexibility offered by the dynamic memory allocation comes with a cost, in terms of more work for the developer to avoid memory leaks, dangling pointers, and so on.