#include "iostream"
using namespace std;
//空指针调用成员函数
class Person
{
public:
void showPerson()
{
cout << "this is person" << endl;
};
void showPersoAge()
{
if(this == NULL)
{
return; //避免传入空指针导致引用异常
}
cout << "age ==" << this->m_Age <<endl;
};
int m_Age;
};
void test01()
{
Person* p = NULL;
p->showPerson(); //空指针可访问成函数----不操作成员变量
p->showPersoAge(); //空指针不可访问成员变量
}
int main(void)
{
test01();
system("pause");
}