Newsgroups: comp.std.c++
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!world!wmm
From: wmm@world.std.com (William M Miller)
Subject: Re: protected != public-to-derived
Message-ID: <1991Mar26.231529.244@world.std.com>
Organization: The World Public Access UNIX, Brookline, MA
References: <1991Mar25.183627.6041@kestrel.edu> <1991Mar25.210620.13970@world.std.com> <1991Mar26.060706.9221@kestrel.edu>
Distribution: comp
Date: Tue, 26 Mar 1991 23:15:29 GMT
Lines: 35

gyro@kestrel.edu (Scott Layson Burson) writes:
> Making the two classes mutual friends doesn't address the situation in
> question, which is that B and some set of other classes are all
> derived from A, and a member function of B has got hold of some object
> other than *this which is some kind of A, but it doesn't know anything
> else about it, and it wants to have access to that A just as it would
> to the A within *this.  What you would have to do is make each derived
> class of A be a friend of A.

No, what I meant was that I would put any information that needed to be
shared among the derived classes into a private member of each derived class
and make the derived classes mutual friends.  Depending on the exact
situation, I'm sure there are a number of other ways to address this type of
problem without changing the semantics of "protected."

> >This sounds like the argument over passive restraints versus seatbelts.
> >It's nice to have that airbag in the steering column in case I forget to
> >buckle up or in case I decide that it's only a short, safe trip -- but it's
> >not free.
>
> Now *I'm* confused -- it sounds like you're making my argument for me.
> That is, I identify the airbag with the access restriction in question
> -- it's there whether I want it or not, and you're quite right, it
> does cost me something.

My point was that it's a cost-benefit tradeoff -- I personally am quite
willing to pay a couple of percent extra for my car in order to have that
airbag there in case it's needed; others don't think it's worth it.
Similarly here -- I think there's a real benefit offered by the current
definition of "protected" and am willing to put up with whatever minor
inconvenience may result; you obviously draw the cost/benefit line in a
different place.  C'est la vie.

-- William M. Miller, Glockenspiel, Ltd.
   wmm@world.std.com
