InterviewSolution
Saved Bookmarks
| 1. |
What is this pointer in C++? |
|
Answer» The MEMBER functions of every object have a pointer named this, which points to the object itself. The value of this is set to the address of the object for which it is called. It can be used to access the DATA in the object it points to. Example class A{ private: int value; public: void setvalue(int x){ this->value=x; }};int main(){ A a; a.setvalue(5); RETURN 0;} |
|