i'm programming in c++ using cocos2dx and when adding a sprite or objects,
this-> addChild(something)
and addChild(something)
works. Both ways come up with same result.
But not only in c++
, this
is used in android programming too (perhaps, all programming languages use "this"?). I've used this in Java to replace ClassName.class, with simple this
. But besides this purpose this
is used in many ways.
But because I haven't gone deep into programming languages, I don't know if they really do the same job (this-> addChild
vs. addChild
AND ClassName.class
vs. this
).
Why do we need this
?
.
.
Self Answer:
this
is a keyword that refers to the current class instance or object in many object-oriented programming languages.
so...just for comfort?