This Keyword Assignment Help

Assignment Help: >> Classes and Objects - This Keyword

The 'This' keyword

The member's functions of each object have access to a sort of magic pointer named this that points to the object itself. Therefore any member function could search out the address of the object of that it is a member.

Example:

// demonstration of this key word

# include<iostream.h>

class sample

{

private:

char chararra[10];

public:

};

void reveal( )

cout<<"my object's address is "<< this;

void main( )

{

sample s1,s2,s3;

s1.reveal( );

s2.reveal( );

s3.reveal( );

}

The program main( ) in this instance creates three objects of type sample, then asks every object to print its address, by using the reveal( ) member function. Given function prints out the value of the pointer.

Output is

my object's address is 0x8f5effec

my object's address is ox8f5effec

my object's address is ox8f5effec

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