1:隐藏的this指针:
①对于类的非静态成员,每一个对象都有自己的一份复制,即每个对象都有自己的数据成员。
②成员函数是每个对象共享的,调用共享的成员函数通过类中隐藏的this指针来找到自己的数据成员。
③类型:类(类型)指针类型
④在const方法中,为当前类类型的const指针类型
⑤用户可以使用this指针访问数据成员。
2:operator
class Complex
{
public:
Complex(double r = 0,double i = 0)
: re(r),im(i)
{}
double Getre() const { return re; }
double Getim() const { return im; }
inline Complex&
_doapl(Complex* ths, const Complex& temp)
{
ths->im += temp.im;
ths->re += temp.re;
return *ths;
}
inline Complex&
operator+=(const Complex& r)
{
return _doapl(this, r);
}
private:
double re, im;
};