成员函数尾巴上的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;

 



posted @ 2016-10-17 14:28  e-data  阅读(71)  评论(0)    收藏  举报