If at some point in my code, I assign 45 to i. Is there a way for my nested class to have access to i? As of now, whenever I create a function that needs both the nested class and the variable i, I am including both the base and nested class in the function. Is there a way I could include only the nested class and still have acces to i?
Peter87
Is there a way for my nested class to have access to i?
There is nothing special about a nested class. You will have to pass the variables to it like you have to do with any other class.
It is incorrect statement. A nested class has no access to non-static data members of the enclosing class.
The author asked: "Is there a way for my nested class to have access to i?" where i is a non-static data member of the enclosing class. And you answered: "There is nothing special about a nested class."
It is incorrect statement. And I pointed out this.
Well, I guess you can argue that there is something special about nested classes. What I meant was that classes can't access non-static members of another class without having an instance of the other class. The same rules apply to nested classes so that was why I said there was nothing special about them.