Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

Explaining This Pointer, Static Members and destructors in C++

Share this post!
 Vote this!

This pointer 

This pointer is used as a pointer to the class object instance by the member function. The address of the class instance is passed as an implicit parameter to the member functions. It is a common knowledge that C++ keeps only one copy of each member function and the data members are allocated memory for all of their instances. Various kind of instances of data is maintained by the use of this pointer.
The keyword this identifies a special type of pointer. Suppose that you create an object named x of class A, and class A has a nonstatic member function f(). If you call the function x.f(), the keyword this in the body of f() stores the address of x. You cannot declare the this pointer or make assignments to it.
A static member function does not have a this pointer.  more...

0 comments:

Post a Comment