What is the advantage of having this/self pointer mandatory explicit?

后端 未结 6 1166
死守一世寂寞
死守一世寂寞 2020-12-08 16:04

What is the advantage of having this/self/me pointer mandatory explicit?

According to OOP theory a method is supposed to operate mainly (only?) on m

6条回答
  •  时光取名叫无心
    2020-12-08 16:33

    What if the arguments to a method have the same name as the member variables? Then you can use this.x = x for example. Where this.x is the member variable and x is the method argument. That's just one (trivial) example.

提交回复
热议问题