Search⌘ K

Allocation of Dynamic Memory

Understand how to allocate memory dynamically in C++ using the new operator. Learn how pointers store the starting address of allocated memory and how to access that space. This lesson builds foundational skills in dynamic memory management necessary for advanced programming.

Introduction

For dynamic allocation, we have to do the following two steps:

  • First, allocate the dynamic space.
  • Then, store the starting address of the dynamic space in the pointer.

new operator:


The unary
...