class A {};
class B : private A {};
class C : private B
{
public:
class D : private A {}; // Error here
};
This code gives the following error (in VS 2013):
nested.cpp(8) : error C2247: 'A' not accessible because 'B' uses 'private' to inherit from 'A'
It gets fixed if I change the definition of D like this:
class D : private ::A {};
Is this correct behavior, and if so why?
At first I thought it was because C inherits privately from B which would hide the base classes. But if I eliminate the "middle man" class B and just use this:
class A {};
class C : private A
{
public:
class D : private A {};
};
The error goes away.