For every object in C++, there is an implicit pointer called this pointer. It is a constant pointer which always points to the current object. Uses of this pointer are as follows: When data member names and function argument names are same, this pointer can be used to distinguish a data member by writing this->member-name. It can be used inside a member function to return the current object by address by writing return *this. The this pointer cannot be used along with static functions as static functions are not part of any object. Following program demonstrates the use of
The post What are the uses of this pointer in C++ appeared first on Coding Security.
What are the uses of this pointer in C++
read more
Tidak ada komentar:
Posting Komentar