From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Unchecked deallocation question
Date: Fri, 26 Nov 2004 10:06:25 +0100
Date: 2004-11-26T10:06:25+01:00 [thread overview]
Message-ID: <hzl9ywp1t6xh$.6ob5swxlfy6e.dlg@40tude.net> (raw)
In-Reply-To: 41a66926$0$25070$ba620e4c@news.skynet.be
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
next prev parent reply other threads:[~2004-11-26 9:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-24 15:38 Unchecked deallocation question Alex R. Mosteo
2004-11-24 17:24 ` Jeffrey Carter
2004-11-24 17:35 ` Alex R. Mosteo
2004-11-24 17:33 ` David Botton
2004-11-25 8:35 ` Martin Krischik
2004-11-25 9:12 ` Alex R. Mosteo
2004-11-25 23:24 ` Adrien Plisson
2004-11-26 4:05 ` Jim Rogers
2004-11-26 10:53 ` Sergey
2004-11-26 9:06 ` Dmitry A. Kazakov [this message]
2004-11-26 18:20 ` Sergey
2004-11-27 8:43 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox