Is nullptr in C++ the same as null in C#?
Seems like no one asked this question on Google or Stackflow.
Is nullptr in C++ the same as null in C#?
Seems like no one asked this question on Google or Stackflow.
In general yes, both assign the null value to pointer like types
It doesn't convert to numeric values in either language. One difference though is that in C++ nullptr
can convert to bool
. This is not true in C#
Yes. In C++, nullptr
is the equivalent of null
in Java, C#, and a variety of other languages. Prior to C++11, it was standard to use NULL
(which was a macro defined as 0); however, nullptr
actually ensures that it can be used only in the context of pointers (whereas NULL
, by virtue of having been defined as 0, can also be used as the return value for a function that returns an int
instead of a pointer, which is counterintuitive), though both nullptr
and NULL
are implicitly convertible to bool
.