Is there any overhead using this-> for accessing a member?

前端 未结 5 1048
死守一世寂寞
死守一世寂寞 2021-01-11 17:33

When accessing a member of some class, I can use e.g.:

this->myVar = 10 

or I can just write:

myVar = 10
5条回答
  •  北恋
    北恋 (楼主)
    2021-01-11 18:17

    There is no difference in meaning (unless there's more than one name myVar visible, in which case the ordinary version could mean a function-local variable while this->myVar means a member). So yes, it's just a matter of style.

提交回复
热议问题