类和对象-空指针访问函数
#include<iostream>
using namespace std;
class person
{
public:
void showpersonname()
{
cout << "是person类" << endl;
}
void showpersonage()
{
if (this == NULL) //此条件语句起保护作用
{
return;
}
cout << "age = " <<this->m_Age<< endl;
}
int m_Age;
};
void test01()
{
person * p=NULL ;
p->showpersonname();
p->showpersonage();
}
int main()
{
test01();
system("pause");
return 0;
}