comp.lang.ada
 help / color / mirror / Atom feed
* Heterogenous_Array_Test: please explain error
@ 2001-06-12 20:32 M. A. Alves
  2001-06-12 19:44 ` Ehud Lamm
  2001-06-12 19:50 ` Ted Dennison
  0 siblings, 2 replies; 8+ messages in thread
From: M. A. Alves @ 2001-06-12 20:32 UTC (permalink / raw)
  To: comp.lang.ada

Isn't this the 'standard' way of implementing an heterogenous array?
Why is it not working?  Please explain the compiler's error on the last
statement.  Thanks.

procedure Heterogenous_Array_Test is

  type Root is tagged record
    Root_Component: Integer := 0;
  end record;

  type Child is new Root with record
    Child_Component: Integer := 0;
  end record;

  type Class_Ptr is access Root'Class;

  Item: array(1 .. 2) of Class_Ptr := (
    1 => new Root,
    2 => new Child);

begin

  Item(1).Root_Component := 11;

  Item(2).Root_Component := 21;

  Item(2).Child_Component := 22;
    -- error: no selector "Child_Component" for type "Root'Class"

end;

-- 
   ,
 M A R I O   data miner, LIACC, room 221   tel 351+226078830, ext 121
 A M A D O   Rua Campo Alegre, 823         fax 351+226003654
 A L V E S   P-4150 PORTO, Portugal        mob 351+939354002




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

end of thread, other threads:[~2001-06-13 17:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-12 20:32 Heterogenous_Array_Test: please explain error M. A. Alves
2001-06-12 19:44 ` Ehud Lamm
2001-06-12 19:50 ` Ted Dennison
2001-06-13  9:52   ` Lutz Donnerhacke
2001-06-13 14:42     ` Ted Dennison
2001-06-13 14:48       ` Ehud Lamm
2001-06-13 15:40         ` Ted Dennison
2001-06-13 17:10           ` Ehud Lamm

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