This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: local class and scoping


> I think I have stumbled on an issue with scoping and local classes. All
> compilation is done on gcc-2.95.2.

Thanks for your bug report. 

> a::init::init() {
>   sA = 5;           // access to static member of enclosing class.
> };

That should not be accepted: a nested class is not automatically
friend of the enclosing class.

> class a {
> public:
>   a() {}
> private:
>   static int sA;
>   class init {
>   public:
>     init();
>   };

If you put

    friend class init;

here, g++ will accept it even with qualification.

Hope this helps,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]