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-Thread: 103376,6a6d9b5a811a96b3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!f14g2000cwb.googlegroups.com!not-for-mail From: "Adrian Hoe" Newsgroups: comp.lang.ada Subject: Re: How to access parent class/object? Date: 25 Mar 2005 00:08:30 -0800 Organization: http://groups.google.com Message-ID: <1111738110.562768.317150@f14g2000cwb.googlegroups.com> References: <1111733830.271744.235420@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: 219.95.230.55 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1111738115 9391 127.0.0.1 (25 Mar 2005 08:08:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 25 Mar 2005 08:08:35 +0000 (UTC) In-Reply-To: <1111733830.271744.235420@f14g2000cwb.googlegroups.com> User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: f14g2000cwb.googlegroups.com; posting-host=219.95.230.55; posting-account=LKUaWwwAAABzCo8SD2jIIt5LtkPzH8ot Xref: g2news1.google.com comp.lang.ada:9972 Date: 2005-03-25T00:08:30-08:00 List-Id: Hi, Sorry for polluting the bandwidth. I posted this thread without thinking hard enough. Stupid me! :-) For the benefits of newbies: I use class wide type to over this problem. package A is type A_Object is tagged private; type A_Object_Access is access all A_Object'Class; ... end A; package B is type B_Object is new A_Object with private; type B_Object_Access is access all B_Object'Class; ... end B; package C is type C_Object is new B_Object with private; type C_Object_Access is access all C_Object'Class; ... end C; package D is type D_Object is new C_Object with private; type D_Object_Access is access all D_Object'Class; ... end D; With the declaration: My_D_Object : D.D_Object_Access; Now, call the procedure with: Process_C (C_Object_Access (My_D_Object)); This should solve the problem. Cheers, -- Adrian Hoe Adrian Hoe wrote: > Hi, > > I have the following codes (abbreviated): > > package A is > type A_Object is tagged private; > ... > end A; > > package B is > type B_Object is new A_Object with private; > ... > end B; > > package C is > type C_Object is new B_Object with private; > ... > end C; > > package D is > type D_Object is new C_Object with private; > ... > end D; > > Now, I have the following declaration: > > My_D_Object is D.D_Object; > > How can I reference the parent objects? > > procedure Process_C (C_Obj : access C_Object); > procedure Process_D (D_Obj : access D_Object); > > How can I pass C_Object and D_Object into Process_C and Process_D > respectively given only My_D_Object is D.D_Object? > > Thanks. > -- > Adrian Hoe