this指针的由来:C++到C的翻译
this指针的作用
指向成员函数所作用的对象
#include <bits/stdc++.h>using namespace std;class Complex{private:int real, imag;public:Complex(double, double);void PutComplex(void);Complex AddOne(void);};Complex::Complex(double r, double i){this->real = r;this->imag = i;}void Complex::PutComplex(void){cout << this->real << ends << this->imag << endl;}Complex Complex::AddOne(void){this->PutComplex();//等价于PutComplex()this->real++;//等价于real++return *this;}int main(void){Complex c1(2, 3);Complex c2 = c1.AddOne();//2 3c2.PutComplex();//3 3return 0;}
this指针和静态成员函数

