+ 1

NULL Vs. 0

Is there any difference between them? (C++) I say this, because I saw #define NULL 0 when I hovered over NULL in Visual Studio.

21st May 2018, 7:59 PM
Zuke
Zuke - avatar
6 Answers
0
You should not use NULL in C++ anymore. You can replace it with nullptr, which is safer. NULL in C++ is more of a 0, but nullptr is always a pointer.
23rd May 2018, 10:31 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 7
0 is an integer value, like any other. Null means "no value assigned".
21st May 2018, 8:10 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
Because "zero seconds" lasts the same timespan as "no seconds" ;)
21st May 2018, 8:16 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
Then, how come time(NULL) and time(0) both work?
21st May 2018, 8:13 PM
Zuke
Zuke - avatar
+ 1
Ooooh! That makes sense. Thanks! :D
21st May 2018, 8:17 PM
Zuke
Zuke - avatar
0
So, int main() and int main(NULL) are the same?
21st May 2018, 8:18 PM
Zuke
Zuke - avatar