0

What's the purpose of 'this' in c++

Help

11th Jul 2022, 12:19 PM
Biagio
2 Answers
+ 5
Have a look at 64.1 of the c++ course. You can re-read the lessons as often as you like.
11th Jul 2022, 12:20 PM
Lisa
Lisa - avatar
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.
11th Jul 2022, 6:16 PM
Erarnitox
Erarnitox - avatar