문제

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