1. Home
  2. Computer Science MCQs
  3. C++ and Object-Oriented Programming
  4. Inside a non-static C++ member function, what is the this…

Added 30 Nov -0001

Inside a non-static C++ member function, what is the this pointer?

  1. A pointer to the function's own stack frame
  2. A pointer to the object on which the member was called Correct answer
  3. A pointer to the class's static data area
  4. A reference to the base class subobject of the current object

Correct answer

B. A pointer to the object on which the member was called

16 views

MCQSEXAM

Explanation

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.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C++ and Object-Oriented Programming MCQs

Practise all C++ and Object-Oriented Programming MCQs

Similar MCQs