Functions and properties can be declared as protected
. These are only accessible
by other stuff inside of that class or from subclasses; they are inaccessible anything outside
of that class hierarchy.
In this case, something()
is protected
, so we cannot call it from main()
.
We can call something()
from somethingElse()
, as somethingElse()
is
implemented on a subclass of Foo
. And, since somethingElse()
is public (the default), we can call
somethingElse()
from main()
and therefore indirectly call something()
from
main()
.
You can learn more about this in:
Tags: