From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5ea4e8c5a1c5a499 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Polymorphism question Date: 1997/02/23 Message-ID: #1/1 X-Deja-AN: 220845283 References: <330C9CB8.41C6@pheno.physics.wisc.edu> Organization: New York University Newsgroups: comp.lang.ada Date: 1997-02-23T00:00:00+00:00 List-Id: 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)