Why is NULL undeclared?

前端 未结 5 1352
死守一世寂寞
死守一世寂寞 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:16

    Don't use NULL, C++ allows you to use the unadorned 0 instead:

    previous = 0;
    next = 0;
    

    And, as at C++11, you generally shouldn't be using either NULL or 0 since it provides you with nullptr of type std::nullptr_t, which is better suited to the task.

提交回复
热议问题