this pointer In C++
When a member function is called using an object, the address of the object is implicitly passed to the member function as the first argument
(by the compiler) The member function collections this address in a pointer named this.
Simple Example of this Pointer In C++
Explanation of the program
In this program, the
'a' is a private member of the class This_Pointer. Also, the arguments received by the member function
printData() is also a. Hence, if we do not use this pointer explicitly both the 'a' will be considered as data members.
© 2016-2019, Codeverb.com - All Rights Reserved