I Wrote a class which includes an pointer to the next Object of the same class. It worked fine. Then i tried to place the class in it's own header h. + .cpp file. Now when i'm trying to compile, i'm getting the following error:(I'm Using Dev cpp)
`NULL' undeclared (first use this function)
(I'm using NULL in the constructor for the pointer to the next Object)
Include a standard header perhaps?
I would venture the following guess. One of the .cpp files that includes the .h file includes it before including anything else (like <stdlib.h> and so forth). You should include your standard library headers first.
I know this makes a difference with Visual Studio, but I'm not sure about DevCpp.
Try renaming the .h file to .hpp
NULL is not declared in C, but is in C++, if I remember correctly.
You could just do:
#ifndef NULL #define NULL 0 #endif
Radagar: NULL is declared in standard header files. I'm not sure why .h -> .hpp would do anything at all ... it sounds silly.
I'm wondering why no one ranted yet... [url http://www.allegro.cc/forums/view_thread.php?_id=331783]
Yeah, I was about to link that 
Almost certianly, that's his problem.
Radagar: NULL is declared in standard header files. I'm not sure why .h -> .hpp would do anything at all ... it sounds silly.
He didn't include any standard header files first off, secondly there's a difference between c and cpp files.
And ofcourse, read the link.
He didn't include any standard header files first off, secondly there's a difference between c and cpp files.
I know both these things, I've read the link (before reading this thread, actually), and your post has no relevance whatsoever to what you quoted.
The "And ofcourse, read the link." part was for the OP.
NULL is declared in <stddef.h> under C and <cstddef> under C++.