A local class can be used to release a resource used in a function. By releasing the resource in the destructor we can guarantee releasing the resource in the presence of exceptions.
In most cases it is better to produce a complete wrapper class rather than the rather trusting implementation shown here.