我想知道如何从ADA中的父类调用重写方法.让我们考虑以下示例.一Parent类有一些方法,它们通过覆盖Child类.Parent类(即Prints)中有一个方法调用它的一些重写方法.但是被覆盖的方法没有被调用!这是一个例子:
---父母---
package Parents is
type Parent is tagged null record;
procedure Prints(Self: in out Parent);
-- these will be overridden
procedure Print1(Self: in out Parent) is null;
procedure Print2(Self: in out Parent) is null;
end Parents;
...
package body Parents is
procedure Prints(Self: in out Parent) is
begin
Put_Line("Parents.Prints: calling prints...");
Self.Print1;
Self.Print2;
end;
end Parents;
Run Code Online (Sandbox Code Playgroud)
---孩子---
With Parents;
package Childs is
type Child is new Parents.Parent with null record;
overriding …Run Code Online (Sandbox Code Playgroud)