Is NULL the same as False in C++

前端 未结 4 959
你的背包
你的背包 2021-01-12 12:03

In C++ (gcc,VS) is NULL considered the same as False. Or more importantly if in a logical statement what does NULL evaluate to. There were a number of other questions but no

4条回答
  •  甜味超标
    2021-01-12 12:19

    In C++, NULL is #defined to 0 (and thus evaluates to false). In C, it is a void*, which also evaluates to false, but its type is not a numeric type. In the standard library (at least on GCC):

    #ifndef __cplusplus
    #define NULL ((void *)0)
    #else   /* C++ */
    #define NULL 0
    #endif  /* C++ */
    

提交回复
热议问题