Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use of the 'this' keyword as a constructor parameter

Status
Not open for further replies.

shilpashetty27

Technical User
Apr 12, 2007
32
CA



I'm not sure what the 'this' keyword does when used as a parameter in a constructor.

For example, pls consider the foll:


class shape
{
private:
int color;
int dim;

public:
shape();
shape(int i);
~shape();

};


int main()
{
shape(this);

}

I'm not sure what the 'this' keyword does. Could anyone please enlighten me?

I appreciate your help and thanks in advance.


cheers,
Shilpa
 
this is a special keyword that gives you the address of the current object.


James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top