struct B {};
struct D : private B {
B* fun () { return new D; } // ok
}
struct DD : public D {
B* foo () { return 0; } // error: ‘struct B B::B’ is inaccessible !
};
This error seems unreasonable to me. If we can use simple B* in global scope then why not in its privately derived classes? g++ demo.
We are Not trying to convert DD* to B*, which is forbidden by the language rules (this, this, this are related questions).
Note that, if I change B* foo() to int foo(), things go fine.
So apparently the compiler thinks
Bis referring to the private constructor ofBrather than the type.Qualifying
Bapparently fixes that error:or this:
I don’t know why that’s happening, but maybe this will help.
Update: maybe it’s related to 11.2.4 of standard? The only problem is that my standardese isn’t good enough to fully understand it.
(sorry for the image, copy/pasting isn’t working for me)