KyaPoocha.com

Huge Collection of Interview Questions


What is “this” pointer? 

The this pointer is a pointer accessible only within the member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions do not have a this pointer. When a nonstatic member function is called for an object, the address of the object is passed as a hidden argument to the function. For example, the following function call

myDate.setMonth( 3 );
can be interpreted this way:
setMonth( &myDate, 3 );

The object’s address is available from within the member function as the this pointer. It is legal, though unnecessary, to use the this pointer when referring to members of the class.



If you liked this question/asnwer, make sure you
Subscribe to KyaPoocha.com RSS feed!


BOOKMARK THIS : BlinkList | del.icio.us | Digg it | Furl | reddit | StumbleUpon | Yahoo MyWeb |