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.
In newer C++ (C++11 and higher), use nullptr
(as pointed out in a comment, thanks).
Otherwise, add
#include <stddef.h>
to get the NULL
definition.
Related Contents:
- What is this weird colon-member (” : “) syntax in the constructor?
- Single quotes vs. double quotes in C or C++
- Why is list initialization (using curly braces) better than the alternatives?
- Multicharacter literal in C and C++
- When is the “typename” keyword necessary? [duplicate]
- What is the meaning of prepended double colon “::”?
- How do I properly delete nodes of linked list in C++
- Const before or const after?
- Is C++ context-free or context-sensitive?
- int a[] = {1,2,}; Why is a trailing comma in an initializer-list allowed?
- What is the difference between these (bCondition == NULL) and (NULL==bCondition)?
- When were the ‘and’ and ‘or’ alternative tokens introduced in C++?
- What are the advantages of list initialization (using curly braces)?
- What does C++ struct syntax “a : b” mean
- What is special about numbers starting with zero?
- Why do people use __ (double underscore) so much in C++
- Why is using the function name as a function pointer equivalent to applying the address-of operator to the function name?
- Can the template parameters of a constructor be explicitly specified?
- What does it mean when a numeric constant in C/C++ is prefixed with a 0?
- Default value of function parameter
- How do you create a static class in C++?
- Concatenate two string literals
- How to break out of a loop from inside a switch?
- Difference between try-catch syntax for function
- c++ array assignment of multiple values
- What does ‘&’ do in a C++ declaration?
- What’s this C++ syntax that puts a brace-surrounded block where an expression is expected?
- What are the distinctions between the various symbols (*,&, etc) combined with parameters? [duplicate]
- Is there any difference between “T” and “const T” in template parameter?
- Is it possible to avoid repeating the class name in the implementation file?
- What does “for(;;)” mean?
- Variable number of parameters in function in C++
- Why put the constant before the variable in a comparison?
- Why does this call the default constructor?
- What’s the syntax for declaring an array of function pointers without using a separate typedef?
- Is there a way to write a large number in C++ source code with spaces to make it more readable? [duplicate]
- Operator Precedence vs Order of Evaluation
- How does virtual inheritance solve the “diamond” (multiple inheritance) ambiguity?
- How do I erase an element from std::vector by index?
- NULL vs nullptr (Why was it replaced?) [duplicate]
- Increasing accuracy of solution of transcendental equation
- Non const lvalue references
- C++11 initializer list fails – but only on lists of length 2
- How to use clock() in C++
- What’s up with the thousands of warnings in standard headers in MSVC -Wall?
- What happens when a computer program runs?
- Linking dll in Visual Studio
- Why does this code with ‘1234’ compile in C++?
- What is *.o file?
- Can I get a non-const C string back from a C++ string?