If not does that mean that I would have to end each function by deleting all local variables if I wanted to prevent 100% of memory leak?
All objects have an associated storage duration. A storage duration describes how long the storage for an object is kept around. Local variables that are not references introduce an object with automatic storage duration, which means that the storage of those objects is automatically destroyed at the end of its scope.
Reference type variables do not introduce an object and may not even require storage of their own, but they still have storage duration (§3.7/3). If a reference does require storage, it will be released according to the reference's storage duration.
As such, any kind of local variable declaration will not leak. In fact, you cannot delete
an object with automatic storage duration. That is only used for objects with dynamic storage duration, which are allocated using new
.