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

后端 未结 6 1205
死守一世寂寞
死守一世寂寞 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:19

    I generally use this (in C++) only when I am writing the assignment operator or the copy constructor as it helps in clearly identifying the variables. Other place where I can think of using it is if your function parameter variable names are same as your member variable names or I want to kill my object using delete this.

提交回复
热议问题