Is nullptr in C ++ the same as null in C #?

Is nullptr in C ++ the same as null in C #?

No one seems to have asked this question on Google or Stackflow.

+6
source share
3 answers

Generally yes, both assign null to a type pointer

  • C #: class, interface, delegate, or pointer types
  • C ++: pointer types or element pointer type

It cannot be converted to numerical values ​​in any language. One difference is that in C ++ nullptr can be converted to bool . This is not true in C #

+11
source

Yes. In C ++, nullptr is the equivalent of null in Java, C #, and many other languages. Prior to C ++ 11, it was standard to use null (which was a macro defined as 0); however, nullptr actually guarantees that it can only be used in the context of pointers (whereas null , since it is defined as 0, can also be used as a return value for a function that returns an int instead of a pointer that is incompatible), although both nullptr and null implicitly converted to bool .

+4
source

Yes, this is the same. This is an invalid pointer.

0
source

All Articles