Computer >> Computer tutorials >  >> Programming >> C++

What should we assign to a C++ pointer: A Null or 0?


In C++, Null is defined as 0. Null or 0 is an integer.

In case of a pointer, we can assign a pointer p as −

Float* p = NULL;
Float* p = 0;
Float* p = nullptr;

3 of them will produce the same result. null ptr is a keyword introduced in C++11 as a replacement to NULL.