|According to the First Rule
of Acquisition, a resource is always allocated in a constructor of an object
whose destructor deallocates this resource. So all resources are encapsulated
in objects. These objects can live in local scopes, global scopes, or be
sub-objects of other objects. Their destruction is guaranteed. If an object
is allocated from the heap, its destruction is also guaranteed, because it
can only live inside its owner object.
|Looking at code written
using the RM precepts, you can easily prove its resource correctness. Just
check that all resources are allocated in constructors, and that the
corresponding destructors deallocate them. That’s all.
|These rules will now be
relaxed without invalidating our argument.