From: Sami Evangelista <sami.evangelista@wanadoo.fr>
Subject: tagged types
Date: Thu, 30 May 2002 17:30:19 +0200
Date: 2002-05-30T15:31:21+00:00 [thread overview]
Message-ID: <3CF6458B.8030307@wanadoo.fr> (raw)
i have declared an abstract type with two derived types like this
type father is null record;
type son1 is new father with record
son1_field : integer;
end record;
type son2 is new father with record
son2_field : boolean;
end record;
type access_son1 is access son1;
type access_son2 is access son2;
then i introduced a list of these elements and a procedure to add an
element to the list like this:
type access_father_class is access all father'class;
type list;
type access_list is access list;
type list is record
element : access_father_class;
next : access_list;
end record;
procedure add(The_list : in out access_list;
The_Element : access_father_class) is
begin
if The_list = null then
The_list := new list;
The_list.element := The_Element;
The_list.next := null;
else
add(The_list.next, The_element);
end if;
end
until there no problem. but how is it possible to add a son1 object to a
list. I have tried this:
my_object : access_son1 := new son1;
my_object.son1.field := 0;
my_list : access_list;
...
add(my_list, my_object);
and it gives me the following error message:
expected type "access_father"
found type "access_son"
Thanks for any help
Sami Evangelista
next reply other threads:[~2002-05-30 15:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-30 15:30 Sami Evangelista [this message]
2002-05-30 19:11 ` tagged types Stephen Leake
2002-05-31 13:13 ` Stephen Leake
-- strict thread matches above, loose matches on Subject: below --
2004-09-12 19:29 Tagged Types Patrice Freydiere
2004-09-13 4:08 David C. Hoos
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox