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.

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 30-Jul-2019

935 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements