comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@acm.org>
To: Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de>
Cc: comp.lang.ada@ada-france.org
Subject: Re: oo programing help needed?
Date: 06 Dec 2003 09:11:31 -0500
Date: 2003-12-06T09:11:31-05:00	[thread overview]
Message-ID: <mailman.29.1070719903.31149.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <bqshoa$h1g$1@a1-hrz.uni-duisburg.de>

Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de> writes:

> shoko <shoko2004@hotmail.com> 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




  reply	other threads:[~2003-12-06 14:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-06 10:21 oo programing help needed? shoko
2003-12-06 12:23 ` Georg Bauhaus
2003-12-06 14:11   ` Stephen Leake [this message]
2003-12-06 15:50     ` Steve
2003-12-06 13:46 ` Martin Krischik
2003-12-07  2:42 ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox