👉🏻 If you want to enjoy the full experience exploring this pdf, try it out here RAII
RAII can be summarized as follows:
encapsulate each resource into a class, where
• the constructor acquires the resource and establishes all class invariants or throws an exception if that cannot be done, • the destructor releases the resource and never throws exceptions;
always use the resource via an instance of a RAII-class that either
• has automatic storage duration or temporary lifetime itself, or • has lifetime that is bounded by the lifetime of an automatic or temporary object.
→ The whole idea is that the acquired resources during initialization of an object gets released when the object goes out of scope
👉🏻 If you want to learn more about RAII, check out this link https://en.cppreference.com/w/cpp/language/raii
By: Malak Amr