Ross,

You don't have to because Free is a static class procedure defined in
TObject, even if you cast the object, it would not have made a difference,
except if you reintroduced Free in your class.  However, I would like to
point out a related issue.  The default destructor of TObject (Destroy) is
virtual.  This means in your class, if you declare a destructor, you must
make sure you override the destructor (use the override keyword), or your
destructor will not be called.  The compiler will generate a warning message
in any case.

Regards,
Dennis.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, 27 August 2001 10:42
> To: Multiple recipients of list delphi
> Subject: [DUG]: Destroying Objects
>
>
> A simple yes/no question.
>
> Should I cast an object to it's defined type before I Free it?
> ie. MyObject(ListBox.Items.Objects[0]).Free
>    or simply ListBox.Items.Objects[0].Free will do?
>
> Cheers,
> Ross.
> ------------------------------------------------------------------
> ---------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to