细心的你一定发现了,使用派生类型要比使用子类型麻烦的多,所以我还是建议多用子类型,避免遗漏new关键字带来的不必要的麻烦。
-- putwage.adb
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Putwage is
type Age is new Integer range 1 .. 100;
type Wage is new Integer;
Bill_Age : Age :=56;
Bill_Wage : Wage := 56;
begin Put("Total wage is");
Put(Integer(Bill_Age)*Integer(Bill_Wage));
New_Line;
end Putwage;