473,511 Members | 16,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NULL not declared in scope

849 Recognized Expert Contributor
I'm writing a class definitionin C++, and I keep getting errors saying "NULL was not declared in previous scope." This happens no matter where in the file NULL is used, except inside a main, it seems. I'm running GCC 4.1.2 on Ubuntu Feisty Fawn (7.04).

An example code snippet is
Expand|Select|Wrap|Line Numbers
  1. #include utility //used later in file
  2. using namespace std;
  3.  
  4. template <typename T> 
  5. struct treeNode{
  6.     T data;
  7.     treeNode<T>* left;
  8.     treeNode<T>* right;
  9.     treeNode<T>* parent;
  10.     bool hasBeenIterated;
  11.     treeNode(const T& d = T()) : data(d) {
  12.         hasBeenIterated = false;
  13.         left = NULL;
  14.         right = NULL;
  15.         parent = NULL;
  16.     }
  17. };
Any help you can give me with this bizarre error would be much appreciated!
Sep 22 '07 #1
2 8678
ruskalym
65 New Member
Use 0 instead. Zero is pointer-type compatible in C++, no need to cast it.
Sep 22 '07 #2
Laharl
849 Recognized Expert Contributor
That worked, thanks.
Sep 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2990
by: Matthew | last post by:
Hello, I have an executable that is calling a DLL I have built. The DLL requires two static libraries to run (genuine statics as opposed to the 'stub' .lib files that still require a DLL). In...
6
2560
by: Oplec | last post by:
Hi, I thought that I understood how C++ allows for the declaration and defining of variables within an if() statement and how the declared variable can be used until the end of the major if()...
5
27965
by: William | last post by:
In Peer.h, I have: class Peer { // ... }; In Overseer.h, I have: #include "Peer.h" #include <vector>
41
9986
by: Alexei A. Frounze | last post by:
Seems like, to make sure that a pointer doesn't point to an object/function, NULL (or simply 0) is good enough for both kind of pointers, data pointers and function pointers as per 6.3.2.3: 3 An...
14
8990
by: Darren L. Weber | last post by:
I am trying to compile a utility to create .avi files. See http://cpbotha.net/im2avi I'm working on Debian etch (a mix of testing/unstable). dweber@dnlweber:~/im2avi-0.4$ g++ --version g++...
2
2190
by: Jeff | last post by:
Hello, I assigned a new object to a local variable ("req") in a function (see below). The local variable "req" is obviously destroyed when the function exits, but should the object referenced by...
8
2277
by: A. Anderson | last post by:
Howdy everyone, I'm experiencing a problem with a program that I'm developing. Take a look at this stack report from GDB - #0 0xb7d782a3 in strlen () from /lib/tls/i686/cmov/libc.so.6 #1 ...
1
144
by: James Kanze | last post by:
On Apr 11, 3:20 am, Ian Collins <ian-n...@hotmail.comwrote: Yes. ADL kicks in, and finds the function declared in scope wurst::foo.
42
3510
by: polas | last post by:
Afternoon all, I have some code (which I thought was OK, but now appreciate is probably not by the standard) which contains int a; ...... if (a==NULL) { ....
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.