I have the following code:
class Base { private: class NestedBase { public: void Do() {} }; public: NestedBase nested; }; int main() { Base b; b.nested.Do();
NestedBase class is a private nested Base class, so it seems natural that line B does not compile. But on the other hand, the variable b has the public member nested , and I can call its Do() method from outside Base (as in line A). What are the exact rules governing access to a private nested class (or its members) in this case? What does the standard say about this?
c ++ inner-classes class-visibility
undermind
source share