C++学习笔记——this指针

//#include<iostream>
//using namespace std;
//
//class Six
//{
//public:
//    int a;
//    Six(int a)
//    {                    //用this指针来区分局部变量和成员变量
//        this->a = a;    //this指针对应的指针类型,例如 "Six*"
//        this->Show();    //通过this指针直接调用成员函数,this指针只有对象创建的时候才有
//    }                    
//    void Show()            //this指针不是成员,是类成员函数的隐含参数
//    {
//        cout << a << endl;
//    }
//
//};
//
//
//int main()
//{
//    Six a1(12);
//    a1.Show();
//
//
//    return 0;
//}

 

posted @ 2022-11-24 22:14  努力的阿坤  阅读(17)  评论(0)    收藏  举报