-- Natural and Positive are subtypes of Integer
-- Subtypes inherit parent type operations
-- Later we will see how to define our own subtypes
with ada.integer_text_io; use ada.integer_text_io;
procedure nat_pos is
n : Natural; -- Negative not allowed
p : Positive; -- Negative and 0 not allowed
begin
-- Integer get works for the subtypes.
get (n); -- Constraint Error if negative value entered
p := n + 1;
put (n);
put (p);
n := -1; -- Compiles, but warns of runtime Constraint Error
end nat_pos;