destroy()
This lesson explores the effects of executing a destructor late.
We'll cover the following...
Chapter overview
We covered the lifetimes of objects in the lifetimes and fundamental operations chapter.
In earlier chapters, you have seen that the objects are prepared for use in the constructor, which is called this()
, and the final operations of objects are applied in the destructor, which is called ~this()
.
For structs and other value types, the destructor is executed at the time when the lifetime of an object ends. For classes and other reference types, it is executed by the garbage collector sometime in the future. The important distinction is that the destructor of ...