This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c++/37112] New: nested inherited class can't access protected members of base class


The following code fails to compile:

class A {
protected:
    int i;
};

class B {
    class C : public A {
    public:
        void foo(A a) { 
            a.i = 1;
        }
    };
};

int main()
{

}

nest2.cpp: In member function 'void B::C::foo(A)':
nest2.cpp:3: error: 'int A::i' is protected
nest2.cpp:10: error: within this context

I can't find anything in the standard that says this should be invalid, but
perhaps I missed it. Thanks for your time and efforts.


-- 
           Summary: nested inherited class can't access protected members of
                    base class
           Product: gcc
           Version: 4.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: darkwingz at yahoo dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37112


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