我有这个代码,它已经在visual studio中编写但我正在eclipse中工作,我正在尝试使其可以编辑eclipse并且我把这个错误抛给了我
..\heap.cpp:104:10: error: 'NULL' was not declared in this scope
代码:
#include"heap.h"
using namespace std;
template<class T>
Heap<T>::Heap() // constructor
{
root = NULL;
size = 0;
}
答案 0 :(得分:2)
Eclipse不是一个编译器,只是一个IDE。我猜你用的是另一个编译器而不是Visual Studio,系统头文件有些不同,导致你的VC ++工作包括不在<the other compiler>
上包含NULL声明。正如Martinho Fernandes所说,你需要包括<stdlib.h>
或<cstdlib>
,或者包含那些包含这些标题的标题。正如另一个问题所说,C ++ 11的方式是<stddef.h>
或<cstddef>
。