Accessing Member data with this
Whenever you call a member function, member function comes into existence along with the value of this set of the address of the object for that it was called. The this pointer can be treated such as any other pointer to an object and can therefore be used to access the data in the object to points
// program demonstrate of accessing member function using this keyword
# include<iostream.h>
class example
{
private:
int value;
public:
inline void display( );
{
this-> value = 35;
cout<<" value contents=" <<this->value;
cout<<endl;
}
void main( )
{
example obj1;
obj1.display( );
}
the output is
contents of the value = 20