POV-Ray : Newsgroups : povray.off-topic : C++ question : Re: C++ question Server Time
28 Jul 2024 22:30:06 EDT (-0400)
  Re: C++ question  
From: Le Forgeron
Date: 4 Oct 2013 03:30:25
Message: <524e6e91@news.povray.org>
Le 03/10/2013 21:59, Anthony D. Baye a écrit :
> Le_Forgeron <jgr### [at] freefr> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.