Sahaj.blogs

Day page

5 Jan 2024

Study

C++ · Memory: new, delete and RAII

Stack vs heap, manual new/delete and why it leaks, and RAII: tying a resource's lifetime to an object's scope.

  • Stack objects are destroyed automatically at the end of their scope; heap objects live until someone deletes them.
  • RAII means acquiring a resource in a constructor and releasing it in the destructor, so cleanup can't be forgotten.

Read the post →