AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What is NULL? (https://forums.alliedmods.net/showthread.php?t=299319)

PartialCloning 07-11-2017 04:52

What is NULL?
 
I see a lot of values set to "NULL" ("SetTouch(NULL);", "m_pGoalEnt = NULL;") in the game's code.

What is NULL equal to?

klippy 07-11-2017 05:20

Re: What is NULL?
 
Equal to 0. Mostly used as a null pointer (C++ has typesafe nullptr for this).

CrazY. 07-11-2017 18:11

Re: What is NULL?
 
No, 0 don't is equal null. 0 is a integer number, null is nothing.

if ($test == null) // equal nothing

if ($test == 0) // equal integer

if (0 == null) // bool false

SpawnerF 07-11-2017 18:20

Re: What is NULL?
 
Quote:

Originally Posted by CrazY. (Post 2534705)
No, 0 don't is equal null. 0 is a integer number, null is nothing.

if ($test == null) // equal nothing

if ($test == 0) // equal integer

if (0 == null) // bool false

He was talking about c++

KliPPy is right it's defined like that

Code:

#define NULL 0
Edit: ( Read also this )
Spoiler

CrazY. 07-11-2017 19:51

Re: What is NULL?
 
Oh, if he's referring to a language and not in general, all right. But it's worth pointing out even so not all languages that identify zero as a null. Anyway... the question is about C++ only, so my topic is off.

fysiks 07-11-2017 20:25

Re: What is NULL?
 
Quote:

Originally Posted by CrazY. (Post 2534705)
No, 0 don't is equal null. 0 is a integer number, null is nothing.

if ($test == null) // equal nothing

if ($test == 0) // equal integer

if (0 == null) // bool false

This is only (and often) true in languages that have dynamically typed variables, variables that can be any type and don't need to be defined as a specific type (e.g. Python, PHP, etc.). In my experience, these are also OO languages.

CrazY. 07-12-2017 10:03

Re: What is NULL?
 
Exactly that, with is quote I was referencing the PHP.

fysiks 07-12-2017 20:39

Re: What is NULL?
 
Quote:

Originally Posted by CrazY. (Post 2534846)
Exactly that, with is quote I was referencing the PHP.

Because clearly this is a PHP forum.

CrazY. 07-12-2017 20:50

Re: What is NULL?
 
Hmm? Why you say that?


All times are GMT -4. The time now is 22:59.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.