This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: declaring a protected member function as friend
- From: Philippe Haution <philippe_haution at yahoo dot fr>
- To: Ralph Gauges <ralph at isis dot local>, gcc-help at gcc dot gnu dot org
- Cc: gauges at eml dot org
- Date: Tue, 22 Mar 2005 13:11:23 +0100 (CET)
- Subject: Re: declaring a protected member function as friend
- Reply-to: philippe dot haution at mines-paris dot org
Hello,
This might answer to your question :
"A name nominated by a friend declaration shall be
accessible in the scope of the class containing the
friend declaration." (ISO C++ standard 11.4.7)
Regards,
PH
--- Ralph Gauges <ralph@isis.local> wrote:
> Hi,
>
> I recently installed gcc4 (20050130) on some of my
> machines and all of the sudden I can not compile
> some code that worked fine with gcc 3.3 (20030304).
> Suddenly if a declare a friend function in some
> class that is a protected member function in another
> class gcc4 complains that the function is protected
> in this context. This is actually correct, but I
> could not find any documentation that this was not
> allowed in C++. Am I doing something wrong, or is
> this a bug since it worked with gcc3?
>
> Ralph
>
> Here is some sample code that compiles on gcc 3.3
> and fails on gcc 4.0
>
> class A{
> Â Â Â protected:
> Â Â Â Â Â Â Â void test(){};
> };
>
> class B{
> Â Â Â public:
> Â Â Â Â Â Â Â friend void A::test();
> };
>
Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails !
Créez votre Yahoo! Mail sur http://fr.mail.yahoo.com/