What is the difference between declaring overriding operations in the visible
part and declaring them in the private part?

Consider the following example:
----------------
package Class is

  type Root is tagged null record;

  procedure Operation (R : in Root);

  type Derived is new Root with null record;

  -- procedure Operation (D : in Derived);  -- overrides

private

  procedure Operation (D : in Derived);  -- overrides

end Class;
-----------------
with Ada.Text_Io;
use  Ada.Text_Io;

package body Class is

  procedure Operation (R : in Root) is
  begin
    Put_Line ("Root");
  end Operation;

  procedure Operation (D : in Derived) is
  begin
    Put_Line ("Derived");
  end Operation;

end Class;
-----------------
with Class;
use  Class;

procedure Tester is

  R : Root;
  D : Derived;

begin

  -- no dispatching calls
  Operation (R);  -- visible
  Operation (D);  -- derived, invisibly overridden

end Tester;
-------------------
The specific operation for object Derived is inherited and invisibly overridden.

Why does this work? What is the difference to overriding it in the visible part?
Please enlighten me.

Christoph Grein
Member of Ada Germany

http://home.T-Online.de/home/Christ-Usch.Grein
[log in to unmask]