Destructor

Destructor[]
within a class is called for an object automatically before its definitions are dropped, when Remove[object] or ClearAll[object] are called. A class needs not to define such a parameterless Destructor method.
This loads the package.
In[1]:=
Click for copyable input
The next example defines a simple class hierarchy with destructor methods.
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
In[4]:=
Click for copyable input
Next, an object is created.
In[5]:=
Click for copyable input
On removal, destructors are automatically called from bottom to top. Apply is used here in order to evaluate obj to the actual object, because Remove does not evaluate its arguments.