comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephe.Leake@nasa.gov>
Subject: Re: virtual destructors
Date: 22 Apr 2003 13:18:56 -0400
Date: 2003-04-22T17:33:46+00:00	[thread overview]
Message-ID: <u3ckacuwv.fsf@nasa.gov> (raw)
In-Reply-To: b83o2t$gd8$1@news.onet.pl

"kat-Zygfryd" <6667@wp.pl> writes:

> Never mind, I didn;t thinf of directly declaring
> 
> procedure Free is new Ada.Unchecked_Deallocation(Base'Class,CBase);
> procedure Free is new Ada.Unchecked_Deallocation(Derived'Class,CDerived);

You also need to ensure that both access types use the same storage
pool. Something like:

for CDerived'Storage_Pool use CBase'Storage_Pool.

> Another question: are there any advantages in using Ada.Finalization
> for objects that will always be dynamically allocated/deallocated
> over simply declaring a Dispose procedure, with frees object's
> components before freeing itself?

Yes. The compiler ensures that Finalize is called. Users will forget
to call Dispose.

-- 
-- Stephe



  parent reply	other threads:[~2003-04-22 17:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-22 14:18 virtual destructors kat-Zygfryd
2003-04-22 14:27 ` Stephen Leake
2003-04-22 14:56   ` kat-Zygfryd
2003-04-22 15:45     ` kat-Zygfryd
2003-04-22 16:34       ` tmoran
2003-04-22 21:32         ` Robert A Duff
2003-04-22 17:18       ` Stephen Leake [this message]
2003-04-22 16:34         ` Simon Wright
2003-04-22 19:57           ` Stephen Leake
2003-04-22 20:19             ` Simon Wright
2003-04-22 21:23             ` Robert A Duff
2003-04-23 15:16         ` Matthew Heaney
2003-04-22 17:31       ` virtual destructors - doesn't seem to work kat-Zygfryd
2003-04-22 17:32         ` Simon Wright
2003-04-22 17:33     ` virtual destructors Matthew Heaney
2003-04-22 17:28 ` Matthew Heaney
2003-04-22 17:40   ` kat-Zygfryd
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox