1.

Which of the following is correct about this pointer in C++?(a) this pointer is passed as a hidden argument in all the functions of a class(b) this pointer is passed as a hidden argument in all non-static functions of a class(c) this pointer is passed as a hidden argument in all static functions of a class(d) this pointer is passed as a hidden argument in all static variables of a classThis question was addressed to me by my college director while I was bunking the class.My enquiry is from C++ Concepts in section Basics Concepts of C++ of C++

Answer»

Right choice is (B) this pointer is passed as a HIDDEN argument in all non-static FUNCTIONS of a class

To explain I would SAY: As static functions are a type of global function for a class so all the object shares the common instance of that static function whereas all the objects have there own instance for non-static functions and HENCE they are passed as a hidden argument in all the non-static members but not in static members.



Discussion

No Comment Found

Related InterviewSolutions