C++ nested classes, access fathers variables [duplicate]
问题 This question already has answers here : Can inner classes access private variables? (5 answers) Closed 3 years ago . The title already says a lot, but basically what i want to do is the following(Example): I have a class called A, and another class inside a called B, like so: class A { int a; class B { void test() { a = 20; } }; }; As you can see my goal is for class B to have access to class A, as it is a nested class. Not this wont work, because B doesn't have access to A, but how can it