[fpc-pascal] Constructors & Destructors 101
jonas.maebe at elis.ugent.be
Fri Apr 3 11:03:54 CEST 2009
On 03 Apr 2009, at 03:43, Richard Ward wrote:
> C) Just out of curiosity, am wondering why FreeAndNil is global
> procedure instead of a method/destructor of TObject.
If you have:
then freeandnil would get, as first (hidden) parameter, the self
pointer. However, this self pointer is a value parameter. So it would
only contain the value of "c", not its address. Hence, there is no way
to set "c" to nil inside the freeandnil method (while setting the
instance variable to nil is the entire reason for using freeandnil).
More information about the fpc-pascal