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, T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c35d69ccf1ab6b78 X-Google-Attributes: gid103376,public From: jsa@alexandria (Jon S Anthony) Subject: Re: Another OOP Question Date: 1996/08/19 Message-ID: #1/1 X-Deja-AN: 175158998 sender: news@organon.com (news) references: <4v609i$fgj@Masala.CC.UH.EDU> organization: Organon Motives, Inc. newsgroups: comp.lang.ada Date: 1996-08-19T00:00:00+00:00 List-Id: In article <4v609i$fgj@Masala.CC.UH.EDU> cosc19z5@Bayou.UH.EDU (Spasmo) writes: > Ok, here's another OOP question about accessing private members. > Right now let's say I have a class called A, and B inherits from > A. Now let's say that B needs to access a private data member > in A -- is there any way I can do this without placing B into > a Child package? I'm not sure I follow this. Do you mean "private" in the C++ sense or in the Ada sense? In the Ada sense, if A and B are in the same package, then you get this for free: package P is type A is tagged private; ... ops for A... type B is new A with private; ... ops for B... private type A is ... type B is ... end P; In the body of P, B's ops can access A's private definition no problem. If you want A and B in separate packages, then in order for the impls of B's ops to have access to the private definition of A, it needs to go into a child package. > The reason I'd like to now is because I'm confronted with such a > scenario and Child packages (among other things) will make all of my > parents members visible which is the last thing I want to do. I don't understand why you make this claim. Children do not make any of the private stuff of the parent visible: package P is type A is tagged private; ... private type A is... end P; package P.C is -- -- None of P's private definitions are visible here. type B is new A with private; ... private -- -- P's private section is visible here and in the body of P.C type B is ... end P.C; with P.C; procedure Proc is -- -- Nothing of P's private section is visible here... ... end Proc; My guess is that you are not clear on child package visibility rules and that you really do want to use a child package and that it will work just fine for what you want to achieve. Lastly, if you mean "private" in the C++ sense, you have to put the actual definitions in the _bodies_ of the packages. The only way for anything else to get at these will be through accessors (public or private) defined in the specification. Nothing outside the body (and any separates) has direct access. /Jon -- Jon Anthony Organon Motives, Inc. 1 Williston Road, Suite 4 Belmont, MA 02178 617.484.3383 jsa@organon.com