How can I access variables outside class scope but inside parent class scope?

Viewed 1398

I have an exam example which ask whether or not can I access the x variable containing the value 1? The solution is that I can, but I'm interested how exactly?

class A {
    int x = 1; //this is what I need access to.
    class B {
        int x = 2;
        void func(int x) {...}
    }
}
3 Answers
Related