From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,64ced24a7e89252e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!not-for-mail From: cjkywt@hotmail.com (Sergey) Newsgroups: comp.lang.ada Subject: Re: Unchecked deallocation question Date: 26 Nov 2004 02:53:30 -0800 Organization: http://groups.google.com Message-ID: References: <41A4AAFF.5060407@mailinator.com> <4540106.PdnsrBBvo5@linux1.krischik.com> <41a66926$0$25070$ba620e4c@news.skynet.be> NNTP-Posting-Host: 81.25.172.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1101466410 11035 127.0.0.1 (26 Nov 2004 10:53:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 26 Nov 2004 10:53:30 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:6502 Date: 2004-11-26T02:53:30-08:00 List-Id: Jim Rogers wrote in message news:... > Adrien Plisson wrote in > news:41a66926$0$25070$ba620e4c@news.skynet.be: > > > Martin Krischik wrote: > >> You should carefully thing if you really need it. Unlike C/C++ the > >> following is actually valid: > >> > >> declare > >> It : Root'Class := Derived'(...); > >> begin > >> ... > >> end; > > > > mmmm, i don't think there is any problem doing this in C++: > > > > class Root; > > class Derived : public Root; > > > > Root &It = Derived( ... ); > > > > it just uses a reference type which is almost the same as ada access > > type but you cannot assign null to it and cannot dereference it. > > > > This is a difference between C++ and Ada. The C++ solution uses > dynamic memory allocation (from the free space or heap) while the > Ada solution uses the stack. An example was posted by Adrien has nothing to do with dynamic memory allocation. As you can see, Derived is allocated from the STACK. >Use of the stack eliminates the need > for explicit allocation and deallocation. > > Jim Rogers