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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,cf56949c9ced83a9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!feed.news.tiscali.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: "Rick Santa-Cruz" Newsgroups: comp.lang.ada Subject: Re: implicit cast and inheritance Date: Sat, 2 Oct 2004 18:32:04 +0200 Organization: T-Online Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.t-online.com 1096734745 03 23765 J7YPXfOLCIPvSotF 041002 16:32:25 X-Complaints-To: usenet-abuse@t-online.de X-ID: ZeX45YZCQejQRGc6ezPu8snaqMfErAIN2D2aUz2J64MRiIaRNtqcrq X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original Xref: g2news1.google.com comp.lang.ada:4571 Date: 2004-10-02T18:32:04+02:00 List-Id: Hi, >> I have a small question. See the following source-code: >> package Pack is >> type Base is tagged >> record >> Value: Integer; >> end record; >> procedure Base_Proc(B: Base); >> >> type Derived is new Base with >> null record; >> end Pack; >> >> And now I have the following source for the main-procedure: >> with Pack; >> use Pack; >> >> procedure main is >> B: Base; >> D: Derived; >> procedure Proc(B: Base) is >> begin >> null; >> end Proc; >> begin >> Pack.Base_Proc(B); -- 1 >> Pack.Base_Proc(D); -- 2 >> Proc(B); -- 3 >> Proc(D); -- 4 >> end main; >> > > In this case, there is one compiled version of the body of Base_Proc, > and the call Base_Proc (D) calls it. D is passed by reference, so the > body doesn't know or care whether it is getting a Base type or a > Derived type. So an implict cast will be done from Derived to Base, so that the body of the Base_Proc(B: Base) method can be called. Is this correct? You told me, that in the package the following will be declared: procedure Base_Proc (B : Derived); But what's then with the body of Pack? Will there be an body of Base_Proc(B: Derived) which is the same as Base_Proc(B: Base), or how does it work? >> If it is in the same package, is then always implicitly done a cast, >> or is the procedure Base_Proc in the derived class "Derived" >> automatically defined with a parameter Type "Derived"? > > There is a difference between declaring a subprogram and providing an > implementation for it. Sadly, I don't understand what you mean with this. Thanks in advance, Rick