Inside a non-static C++ member function, what is the this pointer?
Correct answer
B. A pointer to the object on which the member was called
16 views
B. A pointer to the object on which the member was called
16 views
this is an implicit pointer to the invoking object, so this->member and member name the same variable. It is what allows member functions to return *this for chaining and to disambiguate a parameter that shadows a member. Static member functions have no this pointer because they are not tied to any instance.
Asked in: NTS, PPSC IT, Campus Interviews
Not sure why the answer is B? Ask here and get an explanation.