Chapter 6. Scoping Classes
In section 3.5 we looked at the definition of Resource Acquisition Is Initialization (RAII), and in this chapter we're going to demonstrate some of the different ways in which it can be applied.
RAII is singularly potent when it comes to resource management. We expect that when a
vector<string> goes out of scope, its destructor is called and it releases its contents. As part of this process, all the contained
string instances are also destroyed and release their resources, after which the memory block that the vector used to store the
string instances is released back to the free store. You get all that functionality just by typing a
The treatment here is pure RAII: a scoping instance acquires a resource in its constructor ...