RAII
Applies to: cpp
RAII (Resource Acquisition Is Initialization) ties a resource's lifetime to an object's scope: it is acquired in the constructor and released in the destructor, automatically, when the object goes out of scope. It is how modern C++ manages memory, files, and locks without leaks.
{
std::vector<int> v(1000); // memory acquired
} // destructor frees it here, automatically
See also: const, std-vector