#include <the iostream> the using namespace STD; class Person { public : int Age; void showClass () { COUT << " This is the class Person " << endl; } void showAge () { // the solution, if it is empty direct return IF ( the this == NULL) { return ; } COUT << " age: " << the this -> Age << endl; } }; voidTest () { the Person * P = NULL; // p-> showAge (); will be given as null pointer access member properties feasible p-> showClass (); } int main () { Test (); System ( " PAUSE " ); return 0 ; }
c ++ member function of a null pointer access
Guess you like
Origin www.cnblogs.com/xiximayou/p/12096066.html
Recommended
Ranking