Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Constrained-genericity/Ada/constrained-genericity-1.ada
Normal file
24
Task/Constrained-genericity/Ada/constrained-genericity-1.ada
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
with Ada.Containers.Indefinite_Vectors;
|
||||
|
||||
package Nutrition is
|
||||
type Food is interface;
|
||||
procedure Eat (Object : in out Food) is abstract;
|
||||
|
||||
end Nutrition;
|
||||
|
||||
with Ada.Containers;
|
||||
with Nutrition;
|
||||
|
||||
generic
|
||||
type New_Food is new Nutrition.Food;
|
||||
package Food_Boxes is
|
||||
|
||||
package Food_Vectors is
|
||||
new Ada.Containers.Indefinite_Vectors
|
||||
( Index_Type => Positive,
|
||||
Element_Type => New_Food
|
||||
);
|
||||
|
||||
subtype Food_Box is Food_Vectors.Vector;
|
||||
|
||||
end Food_Boxes;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
type Banana is new Food with null record;
|
||||
overriding procedure Eat (Object : in out Banana) is null;
|
||||
package Banana_Box is new Food_Boxes (Banana);
|
||||
|
||||
type Tomato is new Food with null record;
|
||||
overriding procedure Eat (Object : in out Tomato) is null;
|
||||
package Tomato_Box is new Food_Boxes (Tomato);
|
||||
-- We have declared Banana and Tomato as a Food.
|
||||
Loading…
Add table
Add a link
Reference in a new issue