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 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!news1.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Unchecked deallocation question Date: Fri, 26 Nov 2004 10:06:25 +0100 Message-ID: References: <41A4AAFF.5060407@mailinator.com> <4540106.PdnsrBBvo5@linux1.krischik.com> <41a66926$0$25070$ba620e4c@news.skynet.be> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de t2LBlbldDffU0Xa1iVDaYQiL8wtDmI7aLQNGPEEjqsJXWHghs= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:6496 Date: 2004-11-26T10:06:25+01:00 List-Id: On Fri, 26 Nov 2004 00:24:15 +0100, Adrien Plisson wrote: > 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. Right, the difference appears when Derived is created by a factory: declare It : Root'Class := Create (...); begin Here Create returns Root'Class, so the actual type is unknown until run-time. In C++ this is only possible using heap and pointers. In Ada It will be indeed allocated on the stack. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de