comp.lang.ada
 help / color / mirror / Atom feed
* Can't access record attribute in derived type
@ 2017-03-08 14:15 Mart van de Wege
  2017-03-08 14:24 ` G.B.
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Mart van de Wege @ 2017-03-08 14:15 UTC (permalink / raw)


Hi,

I have the following definitions

private
type Creature is new Base_Creature with record
      Attributes	 : Attribute_Array;
      Gender             : Possible_Gender := Unknown;
      Current_Hit_Points : Integer;
      Parents            : Group_Of_Creatures.List;
      --  An instance of Ada.Containers.Indefinite_Doubly_Linked_Lists
end record;

In child package #1 (Persons):

private
   type Person is new Creature with record
   [...]
and in child package #2 (Knights):
   type Knight is new Person with record
   [...]

I try to read the first element of the Parents attribute in knights.adb
like this:

   function Father (K : in Knight) return Knight is
   begin
      return K.Parents.First_Element;
   end Father;

And the compiler complains:

 "no selector "Parents" for type "Knight" defined"

What am I missing here? The declarations are private, but shouldn't a
tagged type inherit the entire record of its parent type? That means
that it should have a Parents selector, shouldn't it?

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-03-08 22:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-08 14:15 Can't access record attribute in derived type Mart van de Wege
2017-03-08 14:24 ` G.B.
2017-03-08 15:06   ` Mart van de Wege
2017-03-08 19:30     ` Niklas Holsti
2017-03-08 21:05       ` Mart van de Wege
2017-03-08 20:08 ` Randy Brukardt
2017-03-08 21:06   ` Mart van de Wege
2017-03-08 21:12   ` Mart van de Wege
2017-03-08 21:25     ` Mart van de Wege
2017-03-08 21:50       ` Simon Wright
2017-03-08 22:35         ` Mart van de Wege
2017-03-08 21:03 ` Shark8
2017-03-08 21:16   ` Mart van de Wege

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox