K
Kevin Goodsell
Newsnet said:If you perform a delete on a object, which then calls it's destructor
method, and this method is simply empty. How is the original object actually
being deleted?
1) Even empty destructors do work. That work basically consists of
prepare the object to be deallocated.
2) The original object is (obviously) "actually being deleted" by the
runtime system. How that is accomplished is none of your business
(unless you happen to be using your own delete operator).
I can only assume the delete operator calls the destructor
method and then deletes
Replace "deletes" with "deallocates".
the original object
There is no object at this point, only raw memory. See footnote [1].
(outside of the destructor),
which you don't explicitly do yourself.
[1] The lifetime of an object goes like this: 1) Raw memory is
allocated. 2) A constructor is used to transform that raw memory into an
object. 3) The object is used (or not). 4) The destructor is used to
transform the object back into raw memory. 5) The raw memory is deallocated.
In the case of dynamically created objects, the 'new' operator does
steps 1 and 2. The 'delete' operator does steps 4 and 5.
-Kevin