This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ language lawyer question


Gerald Pfeifer <gerald@pfeifer.com> writes:

> Current mainline issues the following error
>
>   x.cc:2: error: `void A::a()' is private
>   x.cc:6: error: within this context
>
> for this snippet:
>
>   class A {
>      void a();
>   };
>
>   class B {
>      friend void A::a();
>   };
>
> I'm not a language lawyer, but is this really correct? (Intuitively, it
> seems quite backwards.)

It seems correct to me, and makes sense.  (I'm not a language lawyer,
however.)

class A can say that class B (or some method in class B) is a friend.
But class B can't claim to be a friend of some private method of class
A.  So I think the example you give above has it backwards: class B
can't poke its way uninvited into class A.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]