This introduces a little pattern I discovered the other day, to enhance encapsulation around safe resource access. Maybe we have some resource which we want to apply Resource Acquisition is Initialization (RAII) to. For any readers not familiar with RAII that may be something like an open file, or a mutex or some other resource for which we care about it being released by the program once the program has finished accessing it. It order to manage this in C++ we typically create a class type which acquires the resource in its constructor, allows access to the acquired resource via public methods and releases the resource in the destructor. The C++ language guarantees that the destructor of such an object will be called when its enclosing scope terminates. class RAIIType { RAIIType(int param1, int param2, const char* param3) : resource(nullptr) { // Call external library function to access resource. resource = acquireTheResource(param1, param2, param3); } ...