declaring a protected member function as friend
Ralph Gauges
ralph@isis.local
Wed Mar 16 15:53:00 GMT 2005
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();
};
More information about the Gcc-help
mailing list