当前位置: 首页 > news >正文

东莞网站建设哪个平台好做苗木的哪个网站效果好

东莞网站建设哪个平台好,做苗木的哪个网站效果好,市场调研报告范文,地方网站总结如果成员函数没有用到this &#xff0c;那么空指针可以直接访问 如果成员函数用到this 指针&#xff0c;就要注意&#xff0c;要判断是否为空&#xff0c;防止程序崩溃 #include<iostream>using namespace std;class Person{public:void show(){//没有 用到this指针&am…
  1. 如果成员函数没有用到this ,那么空指针可以直接访问

  2. 如果成员函数用到this 指针,就要注意,要判断是否为空,防止程序崩溃

     #include<iostream>using namespace std;class Person{public:void show(){//没有 用到this指针,空指针可以访问函数cout << "Person show" << endl;}void showAge(){if (this == NULL){return;}cout << m_Age << endl;}int m_Age;};void test01(){Person *p = NULL;p->show();p->showAge();}int main(){test01();system("pause");return 0;}
    
http://mrfarshtey.net/news/469/

相关文章: