OOPs have two kinds of fields & methods: public and private. Private can't be accessed from outside the class (unless the accessor is a friend class). While I don't remember attempting to directly accessing a private field of a superClass from a subClass, an instantiation of that subClass does have its own copy of that private field that would be used by those methods able to access that private field.FourthWorld wrote: ↑Sat Aug 08, 2020 2:37 amInteresting design challenge, Mark. The rule as I stated it seems consistent, in that behavior1 well have access to behavior2, just as object1 has access to behavior1.
How might we declare that vars in a nested behavior break this rule and be available to something other than its immediate subscriber?
How do OOPs handle this? Do they treat a behavior1 class as though it doesn't exist, and everything up the chain is effectively flattened for the bottommost object using any of them!
Public fields are accessible by anybody. Every subclass has access to all public fields in all its superClasses. When you instantiate a subclass, it has its own copy of all fields(private & public) found in all its superClasses. Subclasses don't have any specific knowledge of from which superclass a method or field comes from. If you wish to explicitly reference a particular superClass's version of a method, you would use className::methodName(....) to call that version of the method. To reference the first available superClass's method you would use super->methodName(....).