004:使用派生类型

       细心的你一定发现了,使用派生类型要比使用子类型麻烦的多,所以我还是建议多用子类型,避免遗漏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;
发布了69 篇原创文章 · 获赞 33 · 访问量 1173

猜你喜欢

转载自blog.csdn.net/dosdiosas_/article/details/105719421