PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed Need Money Easy and Quick?

Behavior of friend class in a namespace.

 List
Subject: Behavior of friend class in a namespace.
Poster: AlanJohnsonawjcs@yahoo.com
Date: Fri, 23 Mar 2007 15:48:41 -0700
Related Postings:  
Consider the following piece of code:

// test.cpp class B ;

namespace N { class A { friend class B ; protected: int i ; } ; }

class B { N::A a ; public: B() { a.i = 42 ; } } ;

g++ 3.4.6 will compile this without complaint. g++ 4.1.0, however, gives the error: test.cpp: In constructor ‘B::B()’: test.cpp:9: error: ‘int N::A::i’ is protected test.cpp:17: error: within this context

If the friend declaration is changed to: friend class ::B ;

then g++ 4.1.0 also accepts the code.

I am trying to determine which (if either) behavior is correct, but I'm having trouble locating the relevant section of the standard. Any help would be appreciated.

-- Alan Johnson

 

Page2Go2.com is not responsible for content of this message.