C
cppaddict
I read that if you access a parent class's private memebers or methods
from within an inner class, those members of methods will
automatically and silently be converted to having package access. This
seems dangerous and I'd like to know how I could design around it.
Here is my current dilemma. I have an EventHandler class whose
handleEvent() method changes with the object's state. I've implemented
this using the Strategy Pattern, where the Strategy objects are inner
classes of EventHandler. The problem is that these Strategy objects
need access to certain private members and methods of their parent.
There is no reason, however, to give package access to these members
and methods. What can I do? Or does this suggest that I need a design
change? Other than this issue, though, I'm quite happy with the
design.
Thanks for any thoughts,
cpp
from within an inner class, those members of methods will
automatically and silently be converted to having package access. This
seems dangerous and I'd like to know how I could design around it.
Here is my current dilemma. I have an EventHandler class whose
handleEvent() method changes with the object's state. I've implemented
this using the Strategy Pattern, where the Strategy objects are inner
classes of EventHandler. The problem is that these Strategy objects
need access to certain private members and methods of their parent.
There is no reason, however, to give package access to these members
and methods. What can I do? Or does this suggest that I need a design
change? Other than this issue, though, I'm quite happy with the
design.
Thanks for any thoughts,
cpp