From: "Rego, P." <pvrego@gmail.com>
Subject: Another question on class constructor
Date: Mon, 7 Nov 2011 18:27:26 -0800 (PST)
Date: 2011-11-07T18:27:26-08:00 [thread overview]
Message-ID: <19338900.553.1320719246503.JavaMail.geo-discussion-forums@yqpp12> (raw)
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;
Currently my code is:
-- test_pkg.ads
package Test_Pkg is
type Test_Class;
type Test_Class_Ptr is access all Test_Class;
task type Primary_Task (This_Test : access Test_Class) is
pragma Storage_Size (1000);
end Primary_Task;
type Test_Class is tagged limited
record
Info : Integer;
Value : Float;
Primary : Primary_Task (Test_Class'Access);
end record;
function Construct (T : access Test_Class) return Test_Class_Ptr;
end Test_Pkg;
-- test_pkg.adb
with Text_IO; use Text_IO;
package body Test_Pkg is
[...]
function Construct (T : access Test_Class) return Test_Class_Ptr is
T_Ptr : constant Test_Class_Ptr := new Test_Class;
begin
T_Ptr.Info := T.Info + 1;
T_Ptr.Value := 0.0;
return T_Ptr;
end Construct;
end Test_Pkg;
So, how can I code it? What should I put in Primary => [...] code? Should I change the definition of Primary : Primary_Task (Test_Class'Access); in Test_Class definition? Thanks.
next reply other threads:[~2011-11-08 2:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-08 2:27 Rego, P. [this message]
2011-11-08 4:32 ` Another question on class constructor Randy Brukardt
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