g++ is denying me access to a type, just because it happens to be a private grand-father. Does this make sense?
struct A {};
struct B : private A {};
struct C : B {
void foo(A const& a) {}
};
Compiling this yields:
1:10: error: ‘struct A A::A’ is inaccessible
6:12: error: within this context
My point is: I never wanted to access A as an ancestor. In fact, if A is a private ancestor of B, shouldn’t this be completely invisible to anybody but B (i.e. C)?
Of course, I could use protected inheritance but in my case it doesn’t really make sense.
This is due to the injected class name from
Ahiding the globalAinsideC. AlthoughAis visible, it is not accessible (since it is imported as private), hence the error. You can accessAby looking it up in the global namespace: