質問

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

  • C#: class, interface, delegate or pointer types
  • C++: pointer types or pointer-to-member type

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.

Yes, it is the same. It is the invalid pointer.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top