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

C++Server Side ProgrammingProgramming

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.

Published on 02-Apr-2019 16:58:51