0
What's the purpose of 'this' in c++
Help
2 Réponses
+ 5
Have a look at 64.1 of the c++ course. You can re-read the lessons as often as you like.
0
What the mentor here said, but here is the TL;DR :
it is just a pointer to current Object you are working with.
edit: the purpose is that methods actually know which Object to work on/with. You can think of methods as just regular functions with the this pointer as an additional argument. And that is actually what they are. if you open a debugger, you can for an x86 executable see the this pointer passed to the "function" through ecx. if you call the function from different objects, the this pointer changes.