Originally posted by Jeff Albertson: Did you mean to ask "Why can't we have static members in an inner class?" I've wondered about that before...
I'm not sure - but it might be to avoid confusion.
Because an inner class is a non-static member of the outer class, one could wonder whether there a static member of the inner class is "exactly one" or "exactly one per outer class instance".
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I'm not sure - but it might be to avoid confusion.
Because an inner class is a non-static member of the outer class, one could wonder whether there a static member of the inner class is "exactly one" or "exactly one per outer class instance".
Obviously it would be the first since static variables belong to the class and there is only one class. I can't think of any reason other than the potential confusion either.
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Ken Blair:
Obviously it would be the first since static variables belong to the class and there is only one class.
I wouldn't find it totally off-base to argue that, since the member class isn't static, semantically there should be one class per instance of the outer class.