TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Content-Transfer-Encoding: 8BIT
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
From: Christoph & Ursula Grein <[log in to unmask]>
Date: Thu, 20 May 1999 15:58:38 +0200
Content-Type: text/plain; charset=ISO-8859-1
MIME-Version: 1.0
Reply-To: Christoph & Ursula Grein <[log in to unmask]>
Parts/Attachments: text/plain (65 lines)
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]

ATOM RSS1 RSS2