Search⌘ K

Types of Allocation

Explore the two types of memory allocation in C++—static and dynamic. Understand when to use each, the limitations of compile-time fixed memory, and how to manage memory dynamically during program execution using new and delete operators.

Introduction

In C++, we can allocate memory in two ways:

  • Static allocation
  • Dynamic allocation

Static allocation


In static allocation, a fixed amount of memory is allocated to the variables or arrays before the execution of the ...