comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: inheritance and private overiding
Date: 2000/05/04
Date: 2000-05-04T00:00:00+00:00	[thread overview]
Message-ID: <wcc8zxq9r8i.fsf@world.std.com> (raw)
In-Reply-To: C2aQ4.97$ml.60170@news.pacbell.net

tmoran@bix.com writes:

> One compiler refuses to compile this code, giving the indicated
> error message.  Other compilers accept it just fine and print
> "in test1" then "in test2".  Who's right?

I don't see anything illegal in this program.
But I could be missing something.

- Bob

> -----------------
> package test1 is
>   type Root is tagged null record;
>   procedure P(X : in out Root);
> end test1;
> 
> with ada.text_io;
> package body test1 is
>   procedure P(X : in out Root) is
>   begin
>     ada.text_io.put_line("in test1");
>   end P;
> end test1;
> 
> with test1;
> package test2 is
>   type Branch is new test1.Root with private;
> private
>   type Branch is new test1.Root with null record;
>   procedure P(X : in out Branch);
> end test2;
> 
> with ada.text_io;
> package body test2 is
>   procedure P(X : in out Branch) is
>   begin
>     ada.text_io.put_line("in test2");
>   end P;
> end test2;
> 
> with test1, test2;
> package test3 is
>   type A is new test1.Root with null record;
>   type B is new test2.Branch with null record;
> end test3;
> 
> with test3;
> procedure test is
>   X : test3.A;
>   Y : test3.B;
> begin
>   test3.P(X);
>   test3.P(Y);   -- One compiler says "expected type A, found type B"
>                 -- others have no complaints
> end test;




      reply	other threads:[~2000-05-04  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-04  0:00 inheritance and private overiding tmoran
2000-05-04  0:00 ` Robert A Duff [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox