nullptr has type std::nullptr_t. It's implicitly convertible to any pointer type. Thus, it'll match std::nullptr_t or pointer types in overload resolution, but not other types such as int.

0 (aka. C's NULL bridged over into C++) could cause ambiguity in overloaded function resolution, among other things:

f(int);
f(foo *);

(Thanks to Caleth pointing this out in the comments.)

Answer from Joe Z on Stack Overflow
🌐
Embedded Artistry
embeddedartistry.com › home › blog › migrating from c to c++: null vs nullptr
Migrating from C to C++: NULL vs nullptr - Embedded Artistry
December 15, 2021 - Since C++11, NULL can be either an integer literal with value zero, or a prvalue of type std::nullptr_t. Because of this ambiguity, I recommend switching exclusively to nullptr.
🌐
Reddit
reddit.com › r/cpp_questions › what is the difference between null and nullptr in cpp ??
r/cpp_questions on Reddit: What is the difference between NULL and nullptr in cpp ??
March 20, 2021 - For example, it is valid to assign an integer to NULL - despite not being a pointer. Alternatively, NULL will be an integer type in templates whereas nullptr will be a unique type (std::nullptr_t) - which can also be overloaded on (e.g.
Discussions

c++ - NULL vs nullptr (Why was it replaced?) - Stack Overflow
I know that in C++ 0x or NULL was replaced by nullptr in pointer-based applications. I'm just curious of the exact reason why they made this replacement? In what scenario is using nullptr over NULL More on stackoverflow.com
🌐 stackoverflow.com
NULL Define in c & c++ differs?! | Handmade Network
Why C++ doesn't define NULL as nullptr is because idiot programmers used NULL as the 0 constant, most probably to avoid "magic number" warnings and nullptr doesn't convert to int implicitly so a #define NULL nullptr would break the C compatibility. More on hero.handmade.network
🌐 hero.handmade.network
June 14, 2016
NULL vs nullptr
Hi, what is the difference between NULL vs nullptr? Thank you Best Regards Marco More on community.gamedev.tv
🌐 community.gamedev.tv
1
0
June 4, 2022
Is C NULL equal to C++11 nullptr - Stack Overflow
I like to use nullptr instead of NULL. Now I call a C function (from libjansson in this case). NULL in C is implementation defined. For nullptr I found that "A null pointer constant is an integral More on stackoverflow.com
🌐 stackoverflow.com
🌐
Sololearn
sololearn.com › en › Discuss › 3097671 › null-vs-nullptr
NULL vs nullptr | Sololearn: Learn to code for FREE!
The difference is that NULL is an integer, nullptr is a pointer type. It is a crucial difference when dealing with (resolving) method overloads. They are not interchangeable*). When you talk pointer, always use nullptr.
🌐
University of Waterloo
ece.uwaterloo.ca › ~dwharder › icsrts › C › 14
NULL vs 0 vs nullptr | University of Waterloo
In the C++-11 standard, they introduced a new representation of a null pointer, namely nullptr which is of type nullptr_t.
🌐
Quora
quora.com › Whats-the-difference-between-NULL-and-nullptr-in-C++
What's the difference between NULL and nullptr in C++? - Quora
Answer (1 of 13): NULL is a “manifest constant” (a [code ]#define[/code] of C) that’s actually an integer that can be assigned to a pointer because of an implicit conversion. nullptr is a keyword representing a value of self-defined type, that can convert into a pointer, but not into integers.
Find elsewhere
🌐
Reddit
reddit.com › r/c_programming › [deleted by user]
[deleted by user] : r/C_Programming
July 23, 2025 - In C, NULL is an implementation-defined value that evaluates to the null pointer constant, possibly cast to void*. nullptr is an explicit null pointer value. As long as you are comparing them to pointers (like the return of fopen), then they are interchangeable.
🌐
Handmade Network
hero.handmade.network › forums › code-discussion › t › 1292-null_define_in_c__c_differs!
NULL Define in c & c++ differs?! | Handmade Network
June 14, 2016 - ratchetfreak Why C++ doesn't define NULL as nullptr is because idiot programmers used NULL as the 0 constant, most probably to avoid "magic number" warnings and nullptr doesn't convert to int implicitly so a #define NULL nullptr would break the C compatibility.
🌐
Medium
medium.com › @pauljlucas › nullptr-in-c23-571782008dad
nullptr in C23. The new nullptr keyword in C23. | by Paul J. Lucas | Medium
July 8, 2025 - Like void* and 0, nullptr implicitly converts to any type of pointer; unlike NULL, it’s guaranteed to be a pointer.
🌐
Microsoft
devblogs.microsoft.com › dev blogs › the old new thing › when msdn says null, is it okay to use nullptr?
When MSDN says NULL, is it okay to use nullptr? - The Old New Thing
March 13, 2019 - But most people would probably prefer you to write NULL or nullptr. As noted, MSDN understands that a significant portion of its readership is not fluent in the subtleties of C and C++. When it writes NULL, it means the obvious thing: A null pointer. You can translate that into the appropriate construction for the language you are using.
🌐
GameDev.tv
community.gamedev.tv › unreal courses › ask
NULL vs nullptr - Ask - GameDev.tv
June 4, 2022 - Hi, what is the difference between NULL vs nullptr? Thank you Best Regards Marco
🌐
Cppreference
en.cppreference.com › w › c › language › nullptr.html
Predefined null pointer constant (since C23) - cppreference.com
The keyword nullptr denotes a predefined null pointer constant. It is a non-lvalue of type nullptr_t.
Top answer
1 of 1
109

In C++11 and beyond, a pointer that is ==NULL will also ==nullptr and vice versa.

Uses of NULL other than comparing with a pointer (like using it to represent the nul byte at the end of a string) won't work with nullptr.

In some cases, NULL is #define NULL 0, as the integer constant 0 is special-cased in C and C++ when you compare it with pointers. This non-type type information causes some problems in both C and C++, so in C++ they decided to create a special type and value that does the same thing in the "proper" use cases, and reliably fails to compile in most of the "improper" use cases.

Insofar as your C++ implementation is compatible with the C implementation you are interoping with (very rare for this not to be true), everything should work.


To be very clear, if ptr is any kind of pointer, then the following expressions are equivalent in C++:

ptr == nullptr
ptr == NULL
ptr == 0
!ptr

As are the following:

ptr = nullptr
ptr = NULL
ptr = 0

and if X is some type, so are the following statements:

X* ptr = nullptr;
X* ptr = NULL;
X* ptr = 0;

nullptr differs when you pass it to a template function that deduces type (NULL or 0 become an int unless passed to an argument expecting a pointer, while nullptr remains a nullptr_t), and when used in some contexts where nullptr won't compile (like char c = NULL;) (note, not char* c=NULL;)

Finally, literally:

NULL == nullptr

is true.

The NULL constant gets promoted to a pointer type, and as a pointer it is a null pointer, which then compares equal to nullptr.


Despite all this, it isn't always true that:

 foo(NULL)

and

 foo(nullptr)

do the same thing.

void bar(int) { std::cout << "int\n"; }
void bar(void*) { std::cout << "void*\n"; }
template<class T>
void foo(T t) { bar(t); }
foo(NULL);
foo(nullptr);

this prints int for NULL and void* for nullptr.

🌐
DEV Community
dev.to › pauljlucas › nullptr-in-c23-1cn6
nullptr in C23 - DEV Community
July 8, 2025 - Like void* and 0, nullptr implicitly converts to any type of pointer; unlike NULL, it’s guaranteed to be a pointer.
🌐
YouTube
youtube.com › shorts › lfRVyljBMu8
Why C++ replaced NULL with nullptr - YouTube
Learn about why C++ introduced the nullptr keyword. nullptr implicitly converts to pointer types, but not to other types like int. This resolves some ambigui...
Published: February 19, 2026
🌐
Quora
codinghub.quora.com › Whats-the-difference-between-NULL-and-nullptr-in-C
http://www.quora.com/Whats-the-difference-between-NULL-and-nullptr-in-C++/answer/Emilio-Garavaglia
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › understanding-nullptr-c
Understanding nullptr in C++ - GeeksforGeeks
Unlike NULL, nullptr cannot be assigned to integer types.
Published: June 9, 2026