Michał Pelc wrote:Could you please verify if I am right here?
Michał,
As you know, it compiles, runs without exception, and prints "Doing it" for me, as well.
Michał Pelc wrote:I believe part about "non-static" might be misleading
Michał,
I really struggled to come up with something that explains why Rule #2 makes sense 100% of the time.
With that said, as you may already know, from page 268 your example appears legal because
A static member cannot call an instance member without referencing an
instance of the class. This shouldn’t be a surprise since static doesn’t require any instances
of the class to even exist.
Obviously, we have the required cat instance in your example. It does appear that this rule seems to have a "precedence" over Rule #2. As you know, that section of the book text does not appear to have an example as elaborate as yours. Sorry that I couldn't be more help.
By the way, I once asked a question somewhere ... essentially the answer was something to the effect of (heavily paraphrasing) "It's a book ... you can't take a single sentence and essentially forget the other sentences in the whole book." Anyway, thanks for the question.
I am looking forward to what others have to say on this!