Re: Why no access specifiers for friends?
Jiang wrote:
As we know the friend declarations introduce the tightest coupling
relationships between a class and its friends, even tighter than
inheritance.
This is strange because the coupling for relationship "is-a" should
be much tighter than relationship "friend-of-a", even in real life.
Why we do not have access specifiers to control the protected
friends or private friends?
I think you're confused by very simplified expressions which
describe the relationship. Inheritance would be more accurately
described by is-an-implementation-of, or
can-be-replaced-in-all-contexts by. Friend, on the otherhand,
means something along the lines of
is-an-intimate-part-of-the-implementation-of.
Maybe I should post this message in comp.std.c++, but I decided
to post it here because this issue is derived from a related thread.
( Sanity check: public/private
http://groups.google.com/group/comp.lang.c++.moderated/browse_frm/thread/f59e8500e81cba2d/786987f601ffd131?hl=en#786987f601ffd131
)
Any comments are welcome.
If there is a change, I'd prefer it to be in the direction of a
type of friendship which allowed access to only certain private
members. In practice, however, I don't think it's worth the
added complexity.
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]