* Re: declaring a protected member function as friend
@ 2005-03-22 12:38 Philippe Haution
2005-03-22 13:20 ` Stuart Brooks
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Haution @ 2005-03-22 12:38 UTC (permalink / raw)
To: Ralph Gauges, gcc-help; +Cc: gauges
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: declaring a protected member function as friend
2005-03-22 12:38 declaring a protected member function as friend Philippe Haution
@ 2005-03-22 13:20 ` Stuart Brooks
0 siblings, 0 replies; 3+ messages in thread
From: Stuart Brooks @ 2005-03-22 13:20 UTC (permalink / raw)
To: gcc-help
> 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)
To clarify, does this then mean that one can never allow a protected method
from class A to have friend access to class B? While this may be in the
standard, it doesn't make sense to me as the friend declaration is not
*calling* the protected method, but allowing the protected method friend
access to itself, which is completely different.
Also, does this then carry over to friend classes? As in ...
class A
{
public:
void pubFunc();
protected:
void protFunc();
};
class B
{
protected:
friend class A;
};
Does this then mean that A::protFunc() doesn't have protected access to B?
^ permalink raw reply [flat|nested] 3+ messages in thread
* declaring a protected member function as friend
@ 2005-03-16 15:53 Ralph Gauges
0 siblings, 0 replies; 3+ messages in thread
From: Ralph Gauges @ 2005-03-16 15:53 UTC (permalink / raw)
To: gcc-help; +Cc: gauges
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 744 bytes --]
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();
};
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-03-22 12:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-22 12:38 declaring a protected member function as friend Philippe Haution
2005-03-22 13:20 ` Stuart Brooks
-- strict thread matches above, loose matches on Subject: below --
2005-03-16 15:53 Ralph Gauges
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).