From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Please help! Aggregate Object - dynamically allocating the objects inside, doesnt work
Date: 1999/01/09
Date: 1999-01-09T00:00:00+00:00 [thread overview]
Message-ID: <fHPQZ0#O#GA.155@pet.hiwaay.net> (raw)
In-Reply-To: 01be3b99$6fe27620$5104fbd1@longslide
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 --
next prev parent reply other threads:[~1999-01-09 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-09 0:00 Please help! Aggregate Object - dynamically allocating the objects inside, doesnt work Craig Garrett
1999-01-09 0:00 ` David C. Hoos, Sr. [this message]
1999-01-09 0:00 ` Craig Garrett
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox