谁能告诉我为什么这个简单的函数调用会返回底部显示的编译器错误?
//This is a type definition that I use below to simplify variable declaration
typedef vector<int> islice;
typedef vector<islice> int2D;
// therefore int2D is of type vector<vector<int> >
// This is the function prototype in the DFMS_process_spectra_Class.hh file
int DumpL2toFile(int2D&);
// This is the type declaration in the caller
int2D L2Data;
// This is the function call where error is indicated
int DumpL2toFile(L2Data); (**line 90 - error indicated here**)
// this is the function body
int DFMS_process_spectra_Class::DumpL2toFile(int2D& L2) {
string file=sL3Path+L2Info.fileName;
fstream os;
os.open(file.c_str(), fstream::out);
os << "Pixel A-counts B-counts" << endl;
char tmp[80];
for (int i=0; i<512; ++i) {
sprintf(tmp,"%5d %8d %8d\n",L2[i][0],L2[i][1],L2[i][2]);
os << string(tmp) << endl;
}
os.close();
return 1;
}
//这是编译命令和错误
g++ -w -g -c src/DFMS_process_spectra_Class.cc -o obj/DFMS_process_spectra_Class.o
src/DFMS_process_spectra_Class.cc:
In member function 'int DFMS_process_spectra_Class::processL2()':
src/DFMS_process_spectra_Class.cc:90: error:
cannot convert 'int2D' to 'int' in initialization
为什么编译器会int2D&
混淆int
?调用、函数原型和函数的int2D
类型一致!!
//这是我在 Mac OS X 10.8.3 上的编译器版本 i686-apple-darwin11-llvm-g++-4.2
顺便说一句,这与我在使用 g++ 4.3 的 Linux 机器上遇到的错误相同
感谢您的帮助,迈克