comp.lang.ada
 help / color / mirror / Atom feed
From: dag@control.lth.se (Dag Bruck)
Subject: Re: Encapsulation in Ada vs. C++ (Was Re: Ichibah [sic] ...)
Date: Tue, 16 Mar 1993 09:51:50 GMT
Date: 1993-03-16T09:51:50+00:00	[thread overview]
Message-ID: <1993Mar16.095150.9735@lth.se> (raw)
In-Reply-To: 1993Mar16.083809@lglsun.epfl.ch

In <comp.lang.ada> magnus@lglsun.epfl.ch (Magnus Kempe) writes:
>dag@control.lth.se (Dag Bruck) writes:
>: A [C++] class grants friendship to other functions or classes, which means
>: that the author of a class controls who gets access to the private
>: members of the class.  You cannot grant yourself access to any random
>: class.
>
>If your class Foo grants "friendship" to a function/class Bar, _anyone_
>can write such a function/class and, having granted itself "friendliness",
>will have access to the internals of Foo.

If we assume that the author of a class also writes the
classes/functions he/she grants friendship, the "one definition rule"
prohibits you from writing a second function or class with the same
name.

The alternative, that the author grants friendship without actually
writing the friend classes/functions, seems highly unlikely.

If you manipulate library files, for example, replace standard
functions with functions you have written yourself, then you can of
course get access to anything.  You may also patch the symboltable or
the objectcode itself.  However, I doubt that Ada is safer in this
respect.

There is a much simpler way to break encapsulation (and I'm sure
Magnus Kempe wants to hear it): write a your own class with the same
contents and copy the bits from the protected object to a look-alike
object with standard C function "memcpy".

I doubt that "unsafe" features of this nature is of any real interest.
Can anyone give a plausible example?


			-- Dag



  reply	other threads:[~1993-03-16  9:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-03-07 19:15 Ichibah flames, and flames out over, Ada 9X John Goodsen
1993-03-08  0:45 ` David Emery
1993-03-08 15:36 ` Tucker Taft
1993-03-08 16:28   ` Michael Feldman
1993-03-08 22:15     ` Gregory Aharonian
1993-03-09 14:20       ` Tucker Taft
1993-03-09 14:55         ` C. Michael Holloway
1993-03-10 14:51         ` Gregory Aharonian
1993-03-09 17:12       ` Harry Koehnemann
1993-03-09 20:54         ` Michael Feldman
1993-03-09 20:14       ` Larry M. Jordan
1993-03-09 17:49     ` Harry Koehnemann
1993-03-09 21:01       ` Michael Feldman
1993-03-09 18:12   ` Tom Wicklund
1993-03-11  8:04     ` Encapsulation in Ada vs. C++ (Was Re: Ichibah [sic] ...) Magnus Kempe
1993-03-16  6:34       ` Dag Bruck
1993-03-16  7:51         ` Magnus Kempe
1993-03-16  9:51           ` Dag Bruck [this message]
1993-03-09 18:53   ` Ichibah flames, and flames out over, Ada 9X Larry M. Jordan
1993-03-09 20:24     ` David Weller
1993-03-09 21:03       ` Michael Feldman
1993-03-12 14:49         ` Tucker Taft
1993-03-12 23:54           ` Michael Feldman
1993-03-16 17:34   ` Robert Firth
  -- strict thread matches above, loose matches on Subject: below --
1993-03-16 22:37 Encapsulation in Ada vs. C++ (Was Re: Ichibah [sic] ...) John Goodsen
replies disabled

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