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,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d7cc034a367221eb,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-05 15:12:28 PST Path: supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!europa.netcrusader.net!199.60.229.5!newsfeed.direct.ca!look.ca!news1.tor.metronet.ca!nntp.magma.ca!news!not-for-mail From: "VC" Newsgroups: comp.lang.ada Subject: accessing subprogram & inheritance problem X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Message-ID: Date: Mon, 05 Feb 2001 23:12:22 GMT NNTP-Posting-Host: 206.191.14.226 X-Trace: news 981414742 206.191.14.226 (Mon, 05 Feb 2001 18:12:22 EST) NNTP-Posting-Date: Mon, 05 Feb 2001 18:12:22 EST Organization: Magma Communications Ltd. Xref: supernews.google.com comp.lang.ada:4951 Date: 2001-02-05T23:12:22+00:00 List-Id: How do I make the following program to compile and work? I would like to have a subprogram pointer in the root class which can be used to point to the subprograms in the child class as well. Is it possible at all with Ada95? Vicky --------------------------------------------------------------- with Ada.Text_Io; use Ada.Text_Io; procedure Mytest is type Root_T; type Action_Ptr_T is access procedure(Object : in Root_T); type Root_T is tagged record Action_Ptr : Action_Ptr_T; end record; procedure Root_Action (Object : in Root_T) is begin Put_Line("Root Action"); end; type Child_T is new Root_T with null record; procedure Child_Action (Object : in Child_T) is begin Put_Line("Child Action"); end; My_Object : Root_T; My_Child : Child_T; begin My_Object.Action_Ptr := Root_Action'Access; My_Object.Action_Ptr(My_Object); -- this printed out "Root Action" My_Child.Action_Ptr := Child_Action'Access; My_Child.Action_Ptr(My_Child); -- would like it to print "Child Action" end Mytest;