In this section, the reader will learn how to allocate and deallocate memory using C++17. You will learn how to use new() and delete() instead of malloc()/free() to increase the type-safety of allocations and deallocations. Various versions of these functions will be explained, including array, aligned, and placement-style allocations.
When writing a program, including system programming, there are a few different types of memory that can be leveraged by the author:
- Global memory
- Stack memory
- Heap memory
Global memory exists in the program itself, is allocated by the OS's loader, and generally exists in two different locations (assuming ELF...