AdaFAQ

Can you access super methods?

Contributors:

Do you mean "call the operation of the type's parent"?

The answer is yes, by converting the object to the parent type, and then invoking the operation.

For example, suppose I have some special kind of bounded stack:

generic
package Stacks.Bounded_G.Special_G is

  type Stack_Type is new Bounded_G.Stack_Type with private;

  procedure Push (...);

end;

-- instantiate the special stack package --

Now let's call the parent Push operation:

 declare
   Stack : Integer_Stacks.Bounded.Special.Stack_Type;
 begin
   Push (1234, On => Bounded.Stack_Type (Stack));
   ...
 end;

Even though the Stack object is of specific type Special.Stack_Type, which has its own version of Push, the Push operation of its parent is invoked.

No, Ada95 does not have a way to say "invoke my parent's operation."

(Matthew Heaney)


Previous | Next | Table of Contents