1 -- Copyright 2012-2016 Free Software Foundation, Inc.
3 -- This program is free software; you can redistribute it and/or modify
4 -- it under the terms of the GNU General Public License as published by
5 -- the Free Software Foundation; either version 3 of the License, or
6 -- (at your option) any later version.
8 -- This program is distributed in the hope that it will be useful,
9 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
10 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 -- GNU General Public License for more details.
13 -- You should have received a copy of the GNU General Public License
14 -- along with this program. If not, see <http://www.gnu.org/licenses/>.
23 type Shape is abstract tagged null record;
25 type Shape_Access is access all Shape'Class;
27 type Drawable is interface;
29 type Drawable_Access is access all Drawable'Class;
31 procedure Draw (D : Drawable) is abstract;
33 type Circle is new Shape and Drawable with record
38 procedure Draw (R : Circle);
40 My_Circle : Circle := ((1, 2), 3);
41 My_Shape : Shape'Class := Shape'Class (My_Circle);
42 My_Drawable : Drawable'Class := Drawable'Class (My_Circle);
44 S_Access : Shape_Access := new Circle'(My_Circle);
45 D_Access : Drawable_Access := new Circle'(My_Circle);
47 type R (MS : Shape_Access; MD : Drawable_Access) is record
51 MR : R := (MS => S_Access, MD => D_Access, E => 42);
53 type Shape_Array is array (1 .. 4) of Shape_Access;
54 type Drawable_Array is array (1 .. 4) of Drawable_Access;
56 S_Array : Shape_Array := (others => S_Access);
57 D_Array : Drawable_Array := (others => D_Access);