Object lifetime Temporary object lifetime Storage reuse Access outside of lifetime Every object has a lifetime, which is a runtime property: for any object, there is a moment during the execution of a program when its lifetime begins, and there is a…