Nullポインタ

1844 ワード

C++ Null   



C++    C++   



        ,             ,         NULL            。   NULL           。



NULL                    。       :



#include <iostream>



using namespace std;



int main ()

{

   int  *ptr = NULL;



   cout << "ptr     " << ptr ;

 

   return 0;

}

             ,        :



ptr     00    ,             。  ,     0         ,                   。     ,        (  ),           。



         ,      if   ,    :



if(ptr)     /*    p   ,    */

if(!ptr)    /*    p   ,    */

  ,                ,         ,                。    ,              ,        。