Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ header include在main.cpp中起作用,但在类中抛出错误_C++_C - Fatal编程技术网

C++ header include在main.cpp中起作用,但在类中抛出错误

C++ header include在main.cpp中起作用,但在类中抛出错误,c++,c,C++,C,我问过这个问题。但是问题似乎是其他的,所以请在这里重新发布 我在main.cpp中包含了标题,示例代码运行得非常好 #include <iostream> #include <Magick++.h> #include <zbar.h> #include <highgui.h> #include <cv.h> using namespace std; using namespace zbar; using namespace cv;

我问过这个问题。但是问题似乎是其他的,所以请在这里重新发布

我在main.cpp中包含了标题
,示例代码运行得非常好

#include <iostream>
#include <Magick++.h>
#include <zbar.h>
#include <highgui.h>
#include <cv.h>

using namespace std;
using namespace zbar;
using namespace cv;

int main (int argc, char **argv){
if(argc < 2) return(1);

// create a reader
ImageScanner scanner;

// configure the reader
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);

// obtain image data
Magick::Image magick(argv[1]);  // read an image file
int width = magick.columns();   // extract dimensions
int height = magick.rows();
Magick::Blob blob;              // extract the raw data
magick.modifyImage();
magick.write(&blob, "GRAY", 8);
const void *raw = blob.data();

// wrap image data
Image image(width, height, "Y800", raw, width * height);

// scan the image for barcodes
int n = scanner.scan(image);

cv::Mat dispImage = imread(argv[1]);

// extract results
for(Image::SymbolIterator symbol = image.symbol_begin();
    symbol != image.symbol_end();
    ++symbol) {
    // do something useful with results
    cout << "decoded " << symbol->get_type_name()
         << " symbol \"" << symbol->get_data() << '"' << endl;
      }
}
// clean up
image.set_data(NULL, 0);

return(0);
}
我甚至试过用它

extern "C"{
    #include <zbar.h>
}
extern“C”{
#包括
}
但是它抛出100个带有C链接的
模板
错误。

根据,构造函数被声明为

Exception(const void * = NULL);

错误表明未声明
NULL
;意思是没有包含任何内容
。您应该能够通过在邪恶标题之前包含它来修复它。

事实上,我也认为这是一个错误<代码>/usr/local/include/zbar/Exception.h:43:错误:此范围中未声明“NULL”。我会试试看。谢谢我试着包括。。。但问题依然存在!但为什么它在main.cpp中工作而在dummy.h中不工作呢?如果NULL是未定义的,那么即使在main.cpp中它也不应该工作,对吗?对不起。。。成功了!!!整晚都睡不着。。。但问题仍然存在<代码>为什么它在main.cpp中工作而在dummy.h中不工作?如果NULL未定义,那么它即使在main.cpp中也不应该工作,对吗?@harsh:您的示例程序包括几个其他头文件;其中一个必须包括
(直接或间接)。
Exception(const void * = NULL);