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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,56db82f3595e6f1e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-06 07:50:55 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!wn14feed!wn13feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!attbi_s03.POSTED!not-for-mail From: "Steve" Newsgroups: comp.lang.ada References: <4948f537.0312060221.6edfa391@posting.google.com> Subject: Re: oo programing help needed? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: NNTP-Posting-Host: 12.211.58.135 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s03 1070725852 12.211.58.135 (Sat, 06 Dec 2003 15:50:52 GMT) NNTP-Posting-Date: Sat, 06 Dec 2003 15:50:52 GMT Organization: Comcast Online Date: Sat, 06 Dec 2003 15:50:53 GMT Xref: archiver1.google.com comp.lang.ada:3179 Date: 2003-12-06T15:50:53+00:00 List-Id: "Stephen Leake" wrote in message news:mailman.29.1070719903.31149.comp.lang.ada@ada-france.org... > Georg Bauhaus writes: > > > shoko wrote: > > : i have the following: > > : ------------------------------------------ > > : package one is > > : type one is tagged private; > > : type one_ptr is access all one'class; > > : > > : procedure set_name(name:String;this:in out one); > > : function get_name(this:one) return string; > > : > > : private > > : type one is tagged > > : record > > : name:String(1..256); > > : end record; > > : > > : > > : end one ; > > ... > > : ------------------------------------------- > > : package body three is > > : function get_name(this:three) return string > > : s:string(1..10); > > : begin > > : return s+ this.name; <-- no selector "name" for type three > > : end get_name; > > > > > > In the definition of one in package one, you have chosen to > > hide .name from view. But then you select a .name component > > from within the body of package three, which as a package > > is just any package, and thus cannot see the private > > part of package one. (You could use get_name in three > > because it is not in the private part of one. This might > > be a good thing to do anyway as it respects the contract > > for dealing with ones using one's public operations.) > > Or, you can make packages Two and Three child packages of One; then > they have visibility to the private part of One. > > Which approach is correct depends on what your full application is. > > -- > -- Stephe > Another alternative (assuming get_name(this:one) does the obvious): with one; package body three is function get_name(this:three) return string is s:string(1..10); begin return s & one.get_name(one.one(this)); end get_name; end three; BTW: It doesn't really take that much extra effort to actually run code you post through the compiler. If you had done so you would have had a few other errors: package three is ... end two; <-- Package name doesn't match package body three is function get_name(this:three) return string <-- Missing "is" s:string(1..10); The "+" operator is not defined to concatenate two strings. Use "&" instead. It's easy to save newsgroup posts and run gnatchop to get source files to test. It is annoying when the files generated don't compile due to errors in the source. Steve (The Duck)