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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ec7ccf8eee6d37fc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-16 12:09:10 PST From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada References: <9gg557$8sgga$1@ID-42131.news.dfncis.de> Subject: Re: virtual functions in ada95 Date: Sat, 16 Jun 2001 14:08:58 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: Newsfeeds.com Message-ID: <3b2bacbe_2@Newsfeeds.com> X-Authenticated-User: 143557362 X-Comments: This message was posted through Newsfeeds.com X-Comments2: IMPORTANT: Newsfeeds.com does not condone, nor support, spam or any illegal or copyrighted postings. X-Report: Report abuse to "abuse@Newsfeeds.com" Organization: Newsfeeds.com http://www.newsfeeds.com 90,000+ UNCENSORED Newsgroups. Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.uchicago.edu!vixen.cso.uiuc.edu!howland.erols.net!netnews.com!feed.cgocable.net!out.nntp.be!propagator-dallas!corp-goliath.newsfeeds.com Xref: archiver1.google.com comp.lang.ada:8808 Date: 2001-06-16T14:08:58-05:00 List-Id: Declare abstract subprograms in the root type, then when that type is extended, the compiler forces you to declare the (concrete) implementation of each abstract subprogram. Then, when the abstract subprogram is invoked, the call dispatches to the implementation according to the derived type with which it was called. "Thomas Nebel" wrote in message news:9gg557$8sgga$1@ID-42131.news.dfncis.de... > Hi > > How can i use virtual functions in Ada? I have a superclass and some classes > that are derived > from it: > > type TNTGL_Custom_Node_Record is tagged null record; > type TNTGL_Node_Record is new TNTGL_Custom_Node_Record with private; > type TNTGL_Visual_Node_Record is new TNTGL_Node_Record with private; > type TNTGL_Sphere_Record is new TNTGL_Visual_Node_Record with private; > > type TNTGL_Node is access all TNTGL_Node_Record'Class; > type TNTGL_Sphere is access all TNTGL_Sphere_Record'Class; > .... > procedure Run (Node : access TNTGL_Node_Record'Class); > procedure Run (Node : access TNTGL_Group_Node_Record'Class); > procedure Run (Sphere : access TNTGL_Sphere_Record'Class); > > Now i want to "run" the classes from one point transparently : > > Node : TNTGL_Node; > ... > Node := Scene.First_Node; > while Node /= null loop > Run (Node); > Node := Get_Next (Node); > end loop; > > Independent of the real type of the Node variable, the Run function is > always the Run from > TNTGL_Node_Record. > > How can i manage it, that the Run function for the real Node type is called > ? > > Thomas > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =-----