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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f5fe096935d4de21 X-Google-Attributes: gid103376,public From: "John G. Volan" Subject: Re: argument of conversion cannot be an allocator Date: 1997/05/17 Message-ID: <337E5B03.20D2@sprintmail.com>#1/1 X-Deja-AN: 242163520 References: <5lbccj$7vk$1@goanna.cs.rmit.edu.au> Organization: Sprint Internet Passport Reply-To: johnvolan@sprintmail.com Newsgroups: comp.lang.ada Date: 1997-05-17T00:00:00+00:00 List-Id: 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? :-) "); ------------------------------------------------------------------------