<legend id='2zB36'><style id='2zB36'><dir id='2zB36'><q id='2zB36'></q></dir></style></legend>
  1. <small id='2zB36'></small><noframes id='2zB36'>

  2. <i id='2zB36'><tr id='2zB36'><dt id='2zB36'><q id='2zB36'><span id='2zB36'><b id='2zB36'><form id='2zB36'><ins id='2zB36'></ins><ul id='2zB36'></ul><sub id='2zB36'></sub></form><legend id='2zB36'></legend><bdo id='2zB36'><pre id='2zB36'><center id='2zB36'></center></pre></bdo></b><th id='2zB36'></th></span></q></dt></tr></i><div id='2zB36'><tfoot id='2zB36'></tfoot><dl id='2zB36'><fieldset id='2zB36'></fieldset></dl></div>
      <bdo id='2zB36'></bdo><ul id='2zB36'></ul>

      <tfoot id='2zB36'></tfoot>

      为什么未声明 NULL?

      Why is NULL undeclared?(为什么未声明 NULL?)
    1. <tfoot id='s3FGA'></tfoot>
          • <bdo id='s3FGA'></bdo><ul id='s3FGA'></ul>

              <tbody id='s3FGA'></tbody>
              <legend id='s3FGA'><style id='s3FGA'><dir id='s3FGA'><q id='s3FGA'></q></dir></style></legend>
              <i id='s3FGA'><tr id='s3FGA'><dt id='s3FGA'><q id='s3FGA'><span id='s3FGA'><b id='s3FGA'><form id='s3FGA'><ins id='s3FGA'></ins><ul id='s3FGA'></ul><sub id='s3FGA'></sub></form><legend id='s3FGA'></legend><bdo id='s3FGA'><pre id='s3FGA'><center id='s3FGA'></center></pre></bdo></b><th id='s3FGA'></th></span></q></dt></tr></i><div id='s3FGA'><tfoot id='s3FGA'></tfoot><dl id='s3FGA'><fieldset id='s3FGA'></fieldset></dl></div>

              <small id='s3FGA'></small><noframes id='s3FGA'>

                本文介绍了为什么未声明 NULL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                当我尝试编译此代码时,此结构构造函数出现问题:

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

                typedef struct Node
                {
                    Node( int data ) //
                    {
                        this->data = data;
                        previous = NULL; // Compiler indicates here
                        next = NULL;
                    }
                
                    int data;
                    Node* previous;
                    Node* next;
                } NODE;
                

                当我来的时候出现这个错误:

                when I come this error occurs:

                linkedlistlinkedlist.h||In constructor `Node::Node(int)':|
                linkedlistlinkedlist.h|9|error: `NULL' was not declared in this scope|
                    ||=== Build finished: 1 errors, 0 warnings ===|
                

                最后一个问题是结构,但它在我的 main.cpp 中工作正常,这次它在头文件中并给了我这个问题.我正在使用 Code::Blocks 来编译这段代码

                Last problem was the struct, but it worked fine when it was in my main.cpp, this time it's in a header file and is giving me this problem. I am using Code::Blocks to compile this code

                推荐答案

                NULL 不是 C 或 C++ 语言中的内置常量.事实上,在 C++ 中它或多或少已经过时了,只需使用纯文字 0 代替,编译器会根据上下文做正确的事情.

                NULL is not a built-in constant in the C or C++ languages. In fact, in C++ it's more or less obsolete, just use a plain literal 0 instead, the compiler will do the right thing depending on the context.

                在较新的 C++(C++11 及更高版本)中,使用 nullptr(如评论中指出的,谢谢).

                In newer C++ (C++11 and higher), use nullptr (as pointed out in a comment, thanks).

                否则,添加

                #include stddef.h>

                获取NULL定义.

                这篇关于为什么未声明 NULL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)

                <small id='1DHrJ'></small><noframes id='1DHrJ'>

                  <tfoot id='1DHrJ'></tfoot>

                      <tbody id='1DHrJ'></tbody>
                  1. <i id='1DHrJ'><tr id='1DHrJ'><dt id='1DHrJ'><q id='1DHrJ'><span id='1DHrJ'><b id='1DHrJ'><form id='1DHrJ'><ins id='1DHrJ'></ins><ul id='1DHrJ'></ul><sub id='1DHrJ'></sub></form><legend id='1DHrJ'></legend><bdo id='1DHrJ'><pre id='1DHrJ'><center id='1DHrJ'></center></pre></bdo></b><th id='1DHrJ'></th></span></q></dt></tr></i><div id='1DHrJ'><tfoot id='1DHrJ'></tfoot><dl id='1DHrJ'><fieldset id='1DHrJ'></fieldset></dl></div>

                    <legend id='1DHrJ'><style id='1DHrJ'><dir id='1DHrJ'><q id='1DHrJ'></q></dir></style></legend>
                    • <bdo id='1DHrJ'></bdo><ul id='1DHrJ'></ul>