Re: need for friend function
On Dec 5, 3:26 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
ManicQin wrote:
[..]
Why strousrup is advising not to use friends?
^^^^^^^^^
I am not sure who (or what) that is.
A misspelling of Stroustrup?
Friendship goes against the data/implementation hiding
principle. If you make something private, that's really only
for you to see.
I don't think that Stroustrup advises unconditionally against
friends. If he had felt that there was never a reason to use a
friend, he wouldn't have added the concept to the language.
The important thing, I think, is to consider friends as part of
the interface of your class. Don't (normally) make anything a
friend that isn't implemented as part of your class
implementation. Used correctly, friends increase encapsulation
and hiding.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34