From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Another question on class constructor
Date: Mon, 7 Nov 2011 22:32:25 -0600
Date: 2011-11-07T22:32:25-06:00 [thread overview]
Message-ID: <j9abcr$ld5$1@munin.nbi.dk> (raw)
In-Reply-To: 19338900.553.1320719246503.JavaMail.geo-discussion-forums@yqpp12
"Rego, P." <pvrego@gmail.com> wrote in message
news:19338900.553.1320719246503.JavaMail.geo-discussion-forums@yqpp12...
>I have a class defined as:
>
> type Test_Class is tagged limited
> record
> Info : Integer;
> Value : Float;
> Primary : Primary_Task (Test_Class'Access);
> end record;
>
> I need build a one-step constructor for my class in the form
>
> function Construct (T : access Test_Class) return Test_Class_Ptr is
> begin
> return new Test_Class'(Info => T.Info + 1,
> Value => 0.0,
> Primary => [WHAT I WANNA KNOW]);
> end Construct;
In Ada 2005 or later, use "<>" to default initialize a component in an
aggregate (which is the only thing you can do with a task). In Ada 95, you
are SOL. (Ask someone else what that means if you don't know. ;-)
function Construct (T : access Test_Class) return Test_Class_Ptr is
begin
return new Test_Class'(Info => T.Info + 1,
Value => 0.0,
Primary => <>);
end Construct;
Randy.
next prev parent reply other threads:[~2011-11-08 4:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-08 2:27 Another question on class constructor Rego, P.
2011-11-08 4:32 ` Randy Brukardt [this message]
2011-11-09 0:40 ` Rego, P.
2011-11-09 1:08 ` Rego, P.
2011-11-09 8:30 ` Simon Wright
2011-11-10 1:25 ` Rego, P.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox