comp.lang.ada
 help / color / mirror / Atom feed
* C++ friend
@ 2001-06-26  0:21 Richard Johnson
  2001-06-26  0:51 ` Jeffrey Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Richard Johnson @ 2001-06-26  0:21 UTC (permalink / raw)


Howdy, could someone point me to a good author or tell me if there is an
equivilent to a C++ friend in Ada95?

If anyone knows of any examples or sources to examples it would be
appreciated :)

I appologize if this subject has already been hashed to death, this is my
first time here :)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: C++ friend
  2001-06-26  0:21 C++ friend Richard Johnson
@ 2001-06-26  0:51 ` Jeffrey Carter
  2001-06-26  2:40 ` James Rogers
  2001-07-03 15:12 ` Georg Bauhaus
  2 siblings, 0 replies; 4+ messages in thread
From: Jeffrey Carter @ 2001-06-26  0:51 UTC (permalink / raw)


Richard Johnson wrote:
> 
> Howdy, could someone point me to a good author or tell me if there is an
> equivilent to a C++ friend in Ada95?
> 
> I appologize if this subject has already been hashed to death, this is my
> first time here :)

You won't find many friends of C++ here.

You can find out if things have been hashed to death by searching in the
comp.lang.ada archives at groups.google.com.

In Ada, encapsulation and information hiding is provided by packages.
Visibility to a package's contents varies by where in the package
something is declared:

Items declared in the visible part of a package specification can be
visible anywhere. This is similar to C++'s "public".

Items declared in the package body are only visible within the package.
This is similar to C++'s "private".

Items declared in the private part of a package specification are
visible within the package, within the private part and body of child
packages, and within all of private child packages. This, I think, is
similar to C++'s "friend".

-- 
Jeff Carter
"Son of a window-dresser."
Monty Python & the Holy Grail



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: C++ friend
  2001-06-26  0:21 C++ friend Richard Johnson
  2001-06-26  0:51 ` Jeffrey Carter
@ 2001-06-26  2:40 ` James Rogers
  2001-07-03 15:12 ` Georg Bauhaus
  2 siblings, 0 replies; 4+ messages in thread
From: James Rogers @ 2001-06-26  2:40 UTC (permalink / raw)


Ada does not have a direct equivalent to C++ friends.

Ada has hierarchical compilation units. Ada compilation units may
be a stand-alone subprogram or a package. The parent in a set
of hierarchical units must be a package.

Ada packages provide three levels of data hiding. Public members are
defined in the package specification before the "private" keyword.
Public members are just like public members in C++.

Private members are defined in the package specification following
the "private" keyword. Ada private members are most like C++
protected members.

Members defined only in a package body are most like C++ private
members. They are visible only within the package body.

Hierarchical compilation units have special visibility into thier
parent package. The public part of the child unit has visibility into
the public part of the parent. The private part of the child unit
has visibility into the public and private parts of the parent.

The child unit has no visibility into the members defined in the
parent package body.

This provide similar capabilities to C++ friends. One difference is
that the parent class in C++ must be modified for the addition of
friends. A parent package in Ada requires no modification for the
creation of child compilation units. This is a benefit because you
can extend capability of stable, released code without changing
the currently released compilation units, saving all the analysis,
documentation, and testing costs associated with re-releasing 
working code.

Remember that an Ada package is NOT a direct equivalent to a C++
class. An Ada package is a unit of encapsulation. Inheritance is
achieved by extending tagged types, which are generally defined in
packages. Data hiding is defined at the package level. Tagged types
a usually either public or private, although a public tagged type
may contain members of private types.

Jim Rogers
Colorado Springs, Colorado USA

Richard Johnson wrote:
> 
> Howdy, could someone point me to a good author or tell me if there is an
> equivilent to a C++ friend in Ada95?
> 
> If anyone knows of any examples or sources to examples it would be
> appreciated :)
> 
> I appologize if this subject has already been hashed to death, this is my
> first time here :)



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: C++ friend
  2001-06-26  0:21 C++ friend Richard Johnson
  2001-06-26  0:51 ` Jeffrey Carter
  2001-06-26  2:40 ` James Rogers
@ 2001-07-03 15:12 ` Georg Bauhaus
  2 siblings, 0 replies; 4+ messages in thread
From: Georg Bauhaus @ 2001-07-03 15:12 UTC (permalink / raw)


Richard Johnson <johnson105@home.com> wrote:
: Howdy, could someone point me to a good author or tell me if there is an
: equivilent to a C++ friend in Ada95?

Maybe this is not _precisely_ what you've asked for, but I've
found The Rationale extremely useful. If you do not have it
already,
http://www.adaic.com/standards/95rat/RAThtml/rat95-p2-4.html

N. Cohen: Ada as a 2nd language, compares C++ and Ada features
in many places.

: If anyone knows of any examples or sources to examples it would be
: appreciated :)

with some luck, in
http://www.adapower.com/lang/


--  Georg
---
Microsoft Windows--a fresh perspective on information hiding



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-07-03 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-26  0:21 C++ friend Richard Johnson
2001-06-26  0:51 ` Jeffrey Carter
2001-06-26  2:40 ` James Rogers
2001-07-03 15:12 ` Georg Bauhaus

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