This document provides an overview of dynamic memory allocation in C++. It discusses the differences between automatic and dynamic arrays, and how dynamic arrays are allocated on the heap using functions like malloc() and free(). The key points covered are:
- Automatic arrays have a fixed size set at compile-time, while dynamic arrays can have a size determined at runtime by allocating memory on the heap.
- Malloc() is used to request a block of memory on the heap and return a void pointer to it, which must then be cast to the proper type.
- When dynamic memory is allocated, the pointer must be checked for null and the memory freed using free() to avoid memory leaks.
- Responsibility for