成员函数尾巴上的const
class complex { public: complex fun() const { return *this; } complex():a(1),b(2){} private: int a; int b; }
complex ad; ad.fun();-->const complex* const this = &ad;
const到底修饰的是谁?——this指针
class complex { public: complex fun() { return *this; } complex():a(1),b(2){} private: int a; int b; } complex ad; ad.fun(); --> complex * const this = &ad;
内在的趣味,表面的繁琐

浙公网安备 33010602011771号