Sense of using 'this' ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Sense of using 'this' ?

If we are able to complete our desired task without making a explicit call to 'this' then where is the need to use it?

28th Dec 2016, 6:47 PM
Pushpendra Singh Rathore
Pushpendra Singh Rathore - avatar
1 Answer
+ 3
The simplest case is to differentiate method arguments from object attributes. E.g.: void setName(name) { this->name = name; }
29th Dec 2016, 5:06 AM
Igor B
Igor B - avatar