This pointer can only be called in a member function of a class. It represents the address of the current object. The following is an example: void Date: setMonth (int mn) {month = mn; // these three sentences are equivalent to this-> month = mn; (* this ). month = mn;} 1. this can only be used in member functions. Global functions and static functions cannot use this. In fact, the first parameter of the member function is T * const register this by default. For example: class A {public: int func (int p) {}}; the prototype of func should be int func (A * const register this, int p); 2. it can be seen that this is constructed before the start of the member function and cleared after the end of the member. This life cycle has the same parameters as any function and has no difference. When a class member function is called, the compiler passes the class pointer as the this parameter of the function. For example, A a;. func (10); here, the compiler will compile it into: A: func (& a, 10); well, it looks no different from A static function, right? However, there are still some differences. The compiler usually optimizes the this pointer. Therefore, the transfer efficiency of this pointer is relatively high-for example, vc usually transmits this parameter through the ecx register. 3. Answer #1: When was this pointer created? This is constructed before the execution of the member function and cleared after the execution of the member. #2: where is this pointer stored? Heap, stack, global variable, or others? This pointer will be placed in different locations due to different compilers. It may be a stack, a register, or even a global variable. #3: How does this pointer pass to functions in the class? Binding? Or if the first parameter of the function parameter is the this pointer, how does the this pointer find the function after the class instance? This is passed through the first parameter of the function parameter. This pointer is generated before the call. The function after the class instance. When the class is instantiated, only the variable space in the class is allocated, and no space is allocated for the function. Since the Function Definition of the class is completed, it is there and won't run. #4: How does this pointer parse the/variable in the class /? If it is not a class but a structure, how can we access the variables in the structure through the structure pointer? If you understand this, you can understand the problem. In C ++, There is only one difference between a class and a structure: the class members are private by default, while the structure is public. This is a class pointer. If it is replaced by a structure, this is the structure pointer. #5: only after we get an object can we use the this pointer through the object. If we know the position of this pointer of an object, can we use it directly? This pointer is defined only in member functions. Therefore, after you obtain an object, you cannot use the this pointer through the object. Therefore, we cannot know the position of the this pointer of an object (this pointer is available only in member functions ). Of course, in a member function, you can know the position of the this pointer (which can be obtained by & this) or directly use it. #6: after each class is compiled, do I create a class letter table to save the function pointer for calling the function? Ordinary Class Functions (whether member functions or static functions) do not create a function table to save function pointers. Only virtual functions are placed in the function table. However, when a virtual function is used, if the compiler can clearly know which function is called, the compiler will not indirectly call the function through the pointer in the function table, but directly call the function. #7: how are these compilers implemented? 8: can it be simulated? After knowing the principles, these two problems are easy to understand. In fact, many people have done this in many cases. For example, the system callback function. There are many system callback functions, such as timing and threads. Example of A thread: class A {int n; public: static void run (void * pThis) {A * this _ = (A *) pThis; this _-> process ();} void process () {}}; main () {A a; _ beginthread (A: run, 0, & );} A static function is defined to simulate the member function. There are also many programs written in C language that simulate the implementation of classes. Such as freetype library. In fact, most people who have used C language have simulated it. There was no clear concept at the time. For example: typedef struct student {int age; int no; int scores;} Student; void initStudent (Student * pstudent); void addScore (Student * pstudent, int score );... if you change pstudent to this, it will be the same. It is equivalent to: class Student {public: int age; int no; int scores; void initStudent (); void addScore (int score);} const constants can have physical storage space, therefore, the // this pointer that can be obtained is created before the object is created. this pointer is placed on the stack and has been determined at the Compilation Time. when an object is created and the entire program is running, there is only one this pointer.