Why is NULL undeclared?

前端 未结 5 1367
死守一世寂寞
死守一世寂寞 2020-11-30 02:55

I have a problem with this struct contructor when I try to compile this code:

typedef struct Node
{
    Node( int data ) //
    {
        this->data = dat         


        
5条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 03:23

    NULL isn't a native part of the core C++ language, but it is part of the standard library. You need to include one of the standard header files that include its definition. #include or #include should be sufficient.

    The definition of NULL is guaranteed to be available if you include cstddef or stddef.h. It's not guaranteed, but you are very likely to get its definition included if you include many of the other standard headers instead.

提交回复
热议问题