I heard that NULL is equivalent to .net nullptr and that 0 is not equivalent to .net nullptr. why? I thought that NULL is a macro equal to 0 ?
Asked
Active
Viewed 340 times
2
-
@Cody, there is. Nullptr is a keyword in the C++/CLI language, around long before C++0x. – Hans Passant Feb 10 '11 at 07:00
1 Answers
1
I depends on if you're talking about unmanaged pointers or managed handles. Regarding pointers, a quote from the documentation here:
The following sample shows that nullptr and zero can be used interchangeably on native
pointers.
However, if you're talking about a managed handle, then you can't use 0 as described in this quote from the same page:
You cannot initialize a handle to zero; only nullptr can be used. Assignment of constant 0 to an object handle produces a boxed Int32 and a cast to Object^.

Hans Olsson
- 54,199
- 15
- 94
- 116