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,659d432f799655b2 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Please help! Aggregate Object - dynamically allocating the objects inside, doesnt work Date: 1999/01/09 Message-ID: #1/1 X-Deja-AN: 430585894 References: <01be3b99$6fe27620$5104fbd1@longslide> Newsgroups: comp.lang.ada X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Date: 1999-01-09T00:00:00+00:00 List-Id: Craig Garrett wrote in message <01be3b99$6fe27620$5104fbd1@longslide>... >I need help. I am probably doing something stupid, but here is my >situation: > >I have an aggregate object (Ada95) called Time_Manager. Its a tagged >record, and two of its fields are pointers (access types) to different >classes. In a procedure I am calling start that is in the Time_Manager >package, I try to use the new operator to dynamically allocate these fields >and get actual objects in there, not just pointers. Pretty standard right? > Its just aggregate objects - thats all. Anyway, the compiler is choking >on it, where I call the new operator. > What compiler are you using? The following code compiles just fine with GNAT. David C. Hoos, Sr. -- begin source code -- with Ada.Calendar; package Sim_Clock is type Object is tagged record Current_Time : Long_Float := 0.0; Last_Time : Long_Float := 0.0; Time_Since_Last : Long_Float := 0.0; Last_Time_Of_Day : Ada.Calendar.Time; Current_Time_Of_Day : Ada.Calendar.Time; end record; type Object_Pointer is access Object; end Sim_Clock; with Ada.Calendar; package Wall_Clock is type Object is tagged record Current_Time, Last_Time : Ada.Calendar.Time := Ada.Calendar.Clock; Time_Since_Last : Duration := 0.0; end record; type Object_Pointer is access Object; end Wall_Clock; with Sim_Clock; with Wall_Clock; package Time_Manager is type Object is tagged record Wall_Time : Wall_Clock.Object_Pointer; Sim_Time : Sim_Clock.Object_Pointer; end record; type Object_Pointer is access Object; procedure Start(This_Time_Manager : in out Object_Pointer); end Time_Manager; package body Time_Manager is procedure Start(This_Time_Manager : in out Object_Pointer) is begin This_Time_Manager.Wall_Time := new Wall_Clock.Object; This_Time_Manager.Sim_Time := new Sim_Clock.Object; end Start; end Time_Manager; -- end source code --