comp.lang.ada
 help / color / mirror / Atom feed
From: James Rogers <jimmaureenrogers@worldnet.att.net>
Subject: Re: C++ friend
Date: Tue, 26 Jun 2001 02:40:51 GMT
Date: 2001-06-26T02:40:51+00:00	[thread overview]
Message-ID: <3B37F6C4.C79E4CAE@worldnet.att.net> (raw)
In-Reply-To: fAQZ6.30950$Mf5.7551625@news3.rdc1.on.home.com

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 :)



  parent reply	other threads:[~2001-06-26  2:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-26  0:21 C++ friend Richard Johnson
2001-06-26  0:51 ` Jeffrey Carter
2001-06-26  2:40 ` James Rogers [this message]
2001-07-03 15:12 ` Georg Bauhaus
replies disabled

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