Re: How to allocate new class instance on the heap?
- From: "Bruce Roberts" <ber@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 25 May 2005 17:01:10 -0400
<chrisspencer02@xxxxxxxxx> wrote in message
news:1117053341.586509.227480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> var
> MyRec : PMyRec;
> begin
> New(MyRec);
> // Do stuff with MyRec
> Dispose(MyRec);
> end;
For additional safety use
New (MyRec);
try
// do stuff with MyRec
finally
Dispose (MyRec);
end;
> Should I use the same method for _class_ instances (with constructors
> and destructors) as I describe for records above? Or is there another
> preferred method?
Absolutely not. Its not a question of being preferred, its a matter of
working correctly. The general form of creating class instances is
ClassInstanceVariable := tClassName.Create { ( <constructor
parameters>) };
.
- Follow-Ups:
- Re: How to allocate new class instance on the heap?
- From: chrisspencer02
- Re: How to allocate new class instance on the heap?
- From: chrisspencer02
- Re: How to allocate new class instance on the heap?
- References:
- How to allocate new class instance on the heap?
- From: chrisspencer02
- How to allocate new class instance on the heap?
- Prev by Date: How to allocate new class instance on the heap?
- Next by Date: Re: analysing a bitmap
- Previous by thread: How to allocate new class instance on the heap?
- Next by thread: Re: How to allocate new class instance on the heap?
- Index(es):