'this Pointer' in C++ Language (part 2)

'this Pointer' in C++ Language

What is 'this Pointer' ?


'this' is a keyword.

this is a local object pointer every instance member function containing address of the caller object.

this pointer can not be modify.

It is used to refer caller object in member function.


Example of 'this pointer'

https://www.studyfreevr.co.in/2018/11/this-pointer-in-c-plus-plus-language-part-2.html

Note:-


Remember this in the quotation given above that the this pointer is called by itself, with all the instant function(if want to learn what is static and instance member click the link) .But if we also want to use this pointer, So we will have to do it within the function because it is a local pointer.

Now know why we need this pointer when we  want  the name of the variable member and instance member are same then we use the this pointer to tell the difference to the compiler because when the compiler sees the same name of both the variables, it will give an error. To avoid this error we used this pointer i.e this-> l=l; this->b=b; this->h=h; so that compiler will understand the difference between these two type of variable i.e the variable which indicate with this keyword will belongs to object variable or without this keyword belong to instance function keyword.



If you have not seen my previous lecture then please click this link and see the previous lecture, so that you can get understand better this lecture.this pointer in C++ Language (part1)



If this article is helpful to you then please like share and comments. thank you..



Comments

Popular posts from this blog

Notepad, Wordpad and Paint

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN