Get instance of containing class

前端 未结 2 555
我寻月下人不归
我寻月下人不归 2020-12-19 17:28

Is it possible to access an object from a member object without passing and storing a reference? In the example below, could a given chair object get access to the house obj

2条回答
  •  一生所求
    2020-12-19 18:10

    First off, is this an example of a real problem or just an example for learning purposes?

    It's definitely not Chair's responsibility to check the house location. If you want to find all chairs in Miami you have to traverse the whole tree or give it a reference.

提交回复
热议问题