Sunday, 13 July 2014

this Pointer

1.The ‘this’ pointer is passed as a hidden argument to all nonstatic member function calls and is available as a local variable within the body of all nonstatic functions.
2.‘this’ pointer is a constant pointer that holds the memory address of the current object.
3.‘this’ pointer is not available in static member functions as static member functions can be called without any object (with class name).
4. For a class X, the type of this pointer is ‘X* const’. Also, if a member function of X is declared as const, then the type of this pointer is ‘const X *const’.
5.  The type of this depends upon function declaration. If the member function of a class X is declared const, the type of this is const X* , if the member function is declared volatile, the type of this is volatile X* , and if the member function is declared const volatile, the type of this is const volatile X*

References:
1. http://www.geeksforgeeks.org/this-pointer-in-c/

No comments:

Post a Comment