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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8b8748382fcfacc1 X-Google-Attributes: gid103376,public From: Julian Day Subject: Re: friend classes in ada95 Date: 2000/04/14 Message-ID: <38F6D9F0.F0DE08E4@geocities.com>#1/1 X-Deja-AN: 611029542 Content-Transfer-Encoding: 7bit References: <38F6B617.34E216A7@emw.ericsson.se> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@cableinet.net X-Trace: news3.cableinet.net 955701512 194.117.145.97 (Fri, 14 Apr 2000 09:38:32 BST) Organization: Cable Internet (post doesn't reflect views of Cable Internet) MIME-Version: 1.0 NNTP-Posting-Date: Fri, 14 Apr 2000 09:38:32 BST Newsgroups: comp.lang.ada Date: 2000-04-14T00:00:00+00:00 List-Id: Stefan Folkesson wrote: > In ADA95, is there a way to make the private part of one class > accessable from another (see friend classes in C++)? > The technique to use is a hierarchical package structure. package X is ... private ... end X; package X.Y is -- Cannot see X's private part private -- Can see X's private part end X.Y; package body X.Y is -- Can see X's private part end X.Y; > > The reason I wonder this is because I want to apply the 'Iterator > Pattern' in my design. This demands that the Iterator object can access > the attributes of the Aggregate object. > Ah, maybe what you really want is the Iterator procedure in your ADT to be generic, like this: generic with Do_Something ( Item : in out Item_Type); proceudre Iterator (ADT : in out ADT_Type); Then you can just instantiate it in your client with what ever procedure you want... > > Is this possible? Is there a pragma to supress the access check or do I > have to declare the attributes of the Aggregate class in the public part > of the specification. Please don't go down that road. HTH, Julian > > > > /Stefan >