C++ language lawyer question

Mike Stump mrs@apple.com
Mon Sep 29 23:46:00 GMT 2003


On Monday, September 29, 2003, at 03:41 PM, Gerald Pfeifer wrote:
> 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.)

Naw, this is an intro to C++ question.  Yes, it is correct.  A friend 
can't claim friendship, the person bestowing friendship must make the 
claim.

class A {
	friend B;
	void a();
};

would allow A::a to work in B.  It is that, or make a public.



More information about the Gcc mailing list