Conceptual
Login

RAII

Resource Acquisition Is Initialization: a resource is acquired in a constructor and released in the destructor, so resource lifetime is tied to object scope and cleanup runs on every exit path, including errors. It generalizes beyond memory to files, locks, and connections.

Questions this Concept answers

  • Why does RAII remove a whole class of leaks from functions that have many early returns?