comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Polymorphism question
Date: 1997/02/23
Date: 1997-02-23T00:00:00+00:00	[thread overview]
Message-ID: <dewar.856702637@merv> (raw)
In-Reply-To: b6afovlqrs.fsf@volkov.i-have-a-misconfigured-system-so-shoot-me


Kirk answered Robert

<<> I have problems to figure out, how Polymorphism works in Ada. I want to
> know if and how the following is possible in Ada:
>
> Suppose I have an abstact type A. Now I have two (non-abstract)
> descendants B and C of A. Furthermore there is a descendant D of C. For
> A an abstract procedure P1 is defined and for B and C P1 is overloaded.
>
> I do also want to be able to call P1 with type D without explicitly
> defining P1 for D, so that the procedure as defined for type C is
> executed with type D.

well, you are out of luck.  you must define P1 for type D separately.  that
is the nature of the abstract definition of P1.
>>


Surely that is wrong. Once you have defined a non-abstract P1 for type C,
then it surely will be inherited by a non-abstract descendent D of C.
Surely we must assume in the above question that D is non-abstract.

package p is
   type a is abstract tagged null record;
   procedure p1 (arg : a) is abstract;

   type b is new a with null record;
   procedure p1 (arg : b);

   type c is new a with null record;
   procedure p1 (arg : c);

   type d is new c with null record;
end p;

type d has a non-abstract p1 available (the one declared for type c)





  reply	other threads:[~1997-02-23  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-20  0:00 Polymorphism question Robert Oeckl
1997-02-20  0:00 ` Samuel Mize
1997-02-23  0:00 ` Kirk Beitz
1997-02-23  0:00   ` Robert Dewar [this message]
1997-02-23  0:00   ` Robert Dewar
replies disabled

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