I do not have a copy of the C++ standard, so I am not sure if this is required behaviour. However, I do know that G++ gives out a somewhat confusing error that could be changed. My test case follows all of the other required information.
The trouble is that G++ doesn't give me an error when I declare class B to be a friend of class A, instead, it just ignores the declaration altogether unless i explicitly qualify B to be foo::B, in which case it works. **G++ version info** Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux Thread model: posix **Command line** g++ testcase.cpp **Errors** [EMAIL PROTECTED] ~]$ g++ testcase.cpp testcase.cpp: In member function void foo::B::do_another(foo::bar::A&): testcase.cpp:20: error: virtual void foo::bar::A::do_something() is protected testcase.cpp:36: error: within this context **Preproccessed Testcase from -save-temps** # 1 "testcase.cpp" # 1 "<built-in>" # 1 "<command line>" # 1 "testcase.cpp" namespace foo { namespace bar { class A; }; class B; }; namespace foo { namespace bar { class A { public: friend class B; protected: virtual void do_something()=0; }; }; class B { public: void do_another(bar::A& a); }; }; using namespace foo; using namespace foo::bar; void B::do_another(A& a) { a.do_something(); } void A::do_something() { } int main ( int argc, char *argv[] ) { } -- Summary: friend classes require explicit qualification when in twin nested namespaces Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: genixpro at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28332