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