分类: C/C++
2011-03-30 22:28:51
The this pointer is used as a
pointer to the object
instance by the member function. The address of the class instance is passed as
an implicit parameter to the member functions. The sample below, in this c++
Tutorial shows how to use it. 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. This kind of various instances of data are maintained use
this pointer. Look at the sample below, in this c++ Tutorial.
C++ Tutorial - important notes on this pointer:
Look at the following example to
understand how to use the 'this' pointer explained in this C++ Tutorial.
class this_pointer_example // class for explaining C++ tutorial |
Thus, a member function can gain the
access of data member by either using this pointer or not.