Ok i am a programmer in Lua for some game sites; and in Lua nil means something isn't defined correctly; therefor it doesn't exist <-- In other words Nil means nothing
NULL is just a macro (defined in WinAPI, I think) which resolves to zero: #define NULL 0
You can have null pointers, i.e. pointers which are 0/NULL (and don't point to anything). But a non pointer variable cannot be null.
1 2 3 4 5 6 7 8 9 10 11 12
#include <string>
int main()
{
std::string str;
str = 0; // try to set a string to 0, i.e. NULL, this generates a compiler error
std::string* pStr;
pStr = 0; // this is OK: we have set a pointer to null
return 0;
}
That is correct, as far as I know. (Of course, you could set, e.g. an integer, to 0, but this is notionally different from the NULL 0 used for pointers...)
And if a pointer is NULL/0, it means it doesn't point to anything. That is, it is a bad pointer and can't be dereferenced, etc.
Actually NULL is defined 0 in C++. In C it is defined as void reference to the address 0: NULL (void*)0
This is not a significant difference, it is like "0" and "-0" for numbers, but it would give a better understanding why NULL is only for pointers (because it is declared as a pointer).
edit:
The way in which is declared NULL in stdio.h (MsVS2005):