From: "John G. Volan" <johnvolan@sprintmail.com>
Subject: Re: argument of conversion cannot be an allocator
Date: 1997/05/17
Date: 1997-05-17T00:00:00+00:00 [thread overview]
Message-ID: <337E5B03.20D2@sprintmail.com> (raw)
In-Reply-To: 5lbccj$7vk$1@goanna.cs.rmit.edu.au
Dale Stanbrough wrote:
>
> I came across the following problem...
>
> type a is tagged private;
> type a_ptr is access all a'class;
>
> type b is new a with private;
> type b_ptr is acces all b'class;
>
> ...
>
>
> return a'(new b);
I assume you meant:
return a_ptr(new b);
>
> which results in the error message (from GNAT)
>
> "argument of conversion cannot be an allocator"
Just so everyone's clear on this, if you're trying to generate an a_ptr,
there is no need to do a type conversion at all:
Your_A_Ptr : A_Ptr := new B;
This is perfectly legal, and it makes perfect sense, too. An A_Ptr
points at any object in type A'Class, which is a classwide type that
covers all objects of type A as well as all types derived from A. This
includes type B.
------------------------------------------------------------------------
Internet.Usenet.Put_Signature
(Name => "John G. Volan", Home_Email => "johnvolan@sprintmail.com",
Slogan => "Ada95: The World's *FIRST* International-Standard OOPL",
Disclaimer => "These opinions were never defined, so using them " &
"would be erroneous...or is that just nondeterministic now? :-) ");
------------------------------------------------------------------------
prev parent reply other threads:[~1997-05-17 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-05-14 0:00 argument of conversion cannot be an allocator Dale Stanbrough
1997-05-14 0:00 ` Peter Hermann
1997-05-16 0:00 ` Dale Stanbrough
1997-05-16 0:00 ` Robert Dewar
1997-05-17 0:00 ` John G. Volan [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox