相关疑难解决方法(0)

Ada中的动态调度

即使使用这个简单的例子,我也无法让动态调度工作.我相信问题在于我如何设置类型和方法,但看不到哪里!

with Ada.Text_Io;
procedure Simple is

   type Animal_T is abstract tagged null record;

   type Cow_T is new Animal_T with record
      Dairy : Boolean;
   end record;

   procedure Go_To_Vet (A : in out Cow_T) is
   begin
      Ada.Text_Io.Put_Line ("Cow");
   end Go_To_Vet;

   type Cat_T is new Animal_T with record
      Fur : Boolean;
   end record;

   procedure Go_To_Vet (A : in out Cat_T)
   is
   begin
      Ada.Text_Io.Put_Line ("Cat");
   end Go_To_Vet;

   A_Cat : Cat_T := (Animal_T with Fur => True);
   A_Cow : Cow_T := (Animal_T with Dairy => …
Run Code Online (Sandbox Code Playgroud)

ada

4
推荐指数
2
解决办法
1755
查看次数

标签 统计

ada ×1