Accessing Member data with This Command Assignment Help

Assignment Help: >> Classes and Objects - Accessing Member data with This Command

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

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd