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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5bb6b79919ca8819 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: problems using classwide types Date: 1997/06/25 Message-ID: #1/1 X-Deja-AN: 252620690 References: <33B10EF3.72B4@dcs.gla.NOSPAM.ac.uk> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-06-25T00:00:00+00:00 List-Id: In article <33B10EF3.72B4@dcs.gla.NOSPAM.ac.uk>, andy billimore wrote: >procedure Main is > L_Check : Check_Type; > TP : Transaction_Ptr_Type; >begin > TP := new Check_Type; > TP := L_Check; -- Error (see below) >end Main; >So I can allocate enough memory to hold an object of Check_Type, but I >can't assign anything to it which I don't understand. You don't have a "classwide types" problem, you have an "access types" problem. The object TP is an access object. It points to an object of type Check_Type, but it not itself a Check_Type. So when you do the assignment TP := L_Check; you are trying to assign an apple (Check_Type) to an orange (a pointer to Check_Type). Just do this TP.all := L_Check; and you should be fine. Of course, you can combine steps: TP : Transaction_Pointer_Type := new Check_Type'(L_Check); which does heap allocation and initialization ("assignment") all in one step. We wouldn't want to create any uninitialized objects, now would we, hmmmm? Hope that helps, Matt -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271