常函数

class Person
{
public:
    //this指针的本质 是指针常量 指针的指向是不可以修改的
    // const Person * const this;
    //在成员函数后面加const  修饰的是this指向,让指针的指向的值也不可以修改
    void showPerson() const
    {
         //m_A = 100; 这句代码实际上是隐式的  this->m_A = 100
        // this = NULL;   this指针不可以修改指针的指向的
    } 
    
    int m_A;
}; 

 

posted @ 2022-08-14 19:46  小白duzw  阅读(93)  评论(0编辑  收藏  举报