Most of C++
programmers are waiting for C++0x
. An interesting feature and a confusing one (at least for me) is the new nullptr
.
Well, no need anymore for the nasty macro NULL
.
int* x = nullptr;
myclass* obj = nullptr;
Still, I am not getting how nullptr
works. For example, Wikipedia article says:
C++0x aims to correct this by introducing a new keyword to serve as a distinguished null pointer constant: nullptr. It will be of type nullptr_t, which is implicitly convertible and comparable to any pointer type or pointer-to-member type. It is not implicitly convertible or comparable to integral types.
How is it a keyword and an instance of a type?
Also, do you have another example (beside the Wikipedia one) where nullptr
is superior to good old 0
?