Which of the following is correct about this pointer in C++?

Minh Phượng

New member
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 class
 
Answer: b
Explanation: 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.
 

Tìm kiếm

Back
Top