POV-Ray : Newsgroups : povray.off-topic : C++ question : Re: C++ question Server Time
28 Jul 2024 16:15:15 EDT (-0400)
  Re: C++ question  
From: Anthony D  Baye
Date: 3 Oct 2013 16:00:01
Message: <web.524dccb71cbd09d0328783aa0@news.povray.org>
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.

At any rate, defining it as warp mentioned using the inline keyword seems to
work, but according to what I've read, that just gives the compiler a hint that
it can be copied in wherever it's called rather than being called as a function.
 I suppose that it won't affect the size of my program all that much, but if I'd
wanted it done that way, I could write it that way. (of course, I understand
that typing a function call is easier than copying a chunk of code several
times)

Anyway, the program compiles now, I just wish I could find out why it was being
so stubborn with the friend function of a class contained in a namespace.

Thanks for the assist.

Regards,
A.D.B


Post a reply to this message

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