Do nested classes obtain friendship relations of outer class?

Viewed 1116
#include <iostream>
#include <string>

class A {
    friend class B;
    std::string m = "Hello";
};

struct B {
    struct N {
        void f(){
            A a;
            std::cout << a.m << std::endl;
        };
    };
};

int main() {
    B::N().f();
}

Is N allowed to access m?

EDIT

Okay I ran it in cpp.sh and obviously it works. Is there a generic rule to understand how friendship relations are obtained?

1 Answers
Related