* Classwide Container
@ 1998-06-08 0:00 Yves Malette
1998-06-08 0:00 ` Dale Stanbrough
0 siblings, 1 reply; 2+ messages in thread
From: Yves Malette @ 1998-06-08 0:00 UTC (permalink / raw)
I am having trouble creating an array of classes.....
that is the simplest way I can say it .... I have included a snippet of
code which can better explain my attempts.....
type Base_Message_Rtype is tagged --base class
record
null;
end record;
type External_Message_Rtype is new Base_Message_Rtype with --some
new class of message
record
with their respective functions
Sent_To : Send_Ptype := Send_Method'Access;
Pending : Pending_Ptype := Pending_Method'Access;
end record;
type Message_Array_Rtype is
array (Messages) of Base_Message_Rtype'Class; -- an array that
can
contain message classes forever
as they become available...
the above example does'nt compile ( BASE_MESSAGE_RTYPE'CLASS must be
constrained )..
which I can agree with......
but I have spent three weeks with my trusty Cohen book and I know I can
constrain it by merely
turning my message_array component into a pointe..(oopss...access
type).....
type Node_Pointer_Type is access Base_Message_Rtype'Class;
type Message_Array_Rtype is
array (Message_Etype) of Node_Pointer_Type;
this will compile, but unfortunately I can only access the methods from
my base class and not
the classwide access expected in the near future.......
(Base_Message_Rtype'Class)
I trying create a simple classwide container............................
I am almost their...any help would
be appreciated
New Ada Guy ....
--
Thanks in advance. Yves Bernard Malette "Expect GREAT Things!"
"Disclaimer about my views and my employer goes here"
+-------------------------------------------------------+
| Raytheon Electronic Systems ph (617) 274 3683 |
| Mail Stop: S1E-K116 |
| 180 Hartwell Road ybm@gbr.msd.ray.com |
| Bedford, MA 01730-2498 |
+-------------------------------------------------------+
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Classwide Container
1998-06-08 0:00 Classwide Container Yves Malette
@ 1998-06-08 0:00 ` Dale Stanbrough
0 siblings, 0 replies; 2+ messages in thread
From: Dale Stanbrough @ 1998-06-08 0:00 UTC (permalink / raw)
Yves Malette writes...
"I am having trouble creating an array of classes....."
type Object is tagged null record;
type Object_Ptr is access all Object'class;
procedure Dispatch (Item : Object);
type Object_Class_Array is array (Integer range <>) of Object_Ptr;
type A is new Object with null record;
procedure Dispatch (Item : A);
etc.
...
List : Object_Class_Array (1..3);
begin
List (1) := new Object;
List (2) := new A;
List (3) := new B;
for i in List'range loop
Dispatch (List (i).all);
end loop;
end;
Hope this helps...
Dale
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-06-08 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-08 0:00 Classwide Container Yves Malette
1998-06-08 0:00 ` Dale Stanbrough
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox