Query about this keyword

what is the functionality of this keyword

hello @prerak_semwal

this pointer is an internal pointer that points to the object.

if member variable and local variable has same name then in that case we use this pointer with member variable to distinguksh between them.

class A{
int x;
A(int x){
    this->x=x;  //here this->x is member variable
                      //and RHS x is local argument u are receiving

}
}
1 Like

@aman212yadav

I just saw that java also has this keyword is there too the same analogy used ?

yeah…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.