この単純な関数呼び出しが、下部に示されているコンパイラ エラーを返す理由を誰か教えてもらえますか?
//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 です。
ちなみに、これは Linux ボックスで g++ 4.3 を使用した場合と同じエラーです。
助けてくれてありがとう、マイク