|
![](/i/fill.gif) |
Le 03/10/2013 21:59, Anthony D. Baye a écrit :
> Le_Forgeron <jgr### [at] free fr> wrote:
>> > Le 03/10/2013 21:20, Le_Forgeron nous fit lire :
>>> > > I forgot that friend functions can access
>>>> > >> protected members, but not private members,
>> >
>> > Hummm... friend can access private. There is no reserved intimacy for
>> > friend.
> Not according to the test I did about an hour ago. I declared the function as a
> friend in point3d and defined it in point3d.cpp, and got told off by g++ for
> attempting to access point3d's private members.
because the implementation you provided was not for the one declared as
friend.
It looked like they referred to the same, but it was a totally different
function. Beware of implicit namespaces. (and having "using.." in header
file at global scope is bad practice: you contaminate every next
included files, as well as the source files)
The only thing a friend does not have access to is inheriting classes :
friendship is not inherited, it has to be reasserted explicitly.
--
Just because nobody complains does not mean all parachutes are perfect.
Post a reply to this message
|
![](/i/fill.gif) |