5,321
edits
(→RAII) |
|||
Line 626: | Line 626: | ||
[https://en.cppreference.com/w/cpp/language/raii cppreference raii]<br> | [https://en.cppreference.com/w/cpp/language/raii cppreference raii]<br> | ||
Resource Acquisition Is Initialization - binds the life cycle of a resource to the lifetime of an object.<br> | Resource Acquisition Is Initialization - binds the life cycle of a resource to the lifetime of an object.<br> | ||
For instance, the resource for a vector is an allocated amount of memory. Once the vector is destroyed | For instance, the resource for a vector is an allocated amount of memory. Once the vector is destroyed and the destructor called, the resource is released.<br> | ||
In general, each RAII object should have all of the following: | In general, each RAII object should have all of the following: | ||
* Constructor acquiring resources | * Constructor acquiring resources |