这些都是涉及到的两个功能:C++编译器错误“不匹配功能”
int FixedLengthRecordFile :: write (const int numRec, const FixedLengthFieldsRecord & rec)
{
/*** some code ***/
return rec.write(file); // FILE* file is an attribute of FixedLengthRecordFile
}
int FixedLengthFieldsRecord :: write (FILE* file) { /* ... code ... */ }
而且我得到这个错误:
FixedLengthRecordFile.cpp: In member function ‘int FixedLengthRecordFile::write(int, const FixedLengthFieldsRecord&)’:
FixedLengthRecordFile.cpp:211:23: error: no matching function for call to ‘FixedLengthFieldsRecord::write(FILE*&) const’
FixedLengthRecordFile.cpp:211:23: note: candidate is:
FixedLengthFieldsRecord.h:35:7: note: int FixedLengthFieldsRecord::write(FILE*) <near match>
FixedLengthFieldsRecord.h:35:7: note: no known conversion for implicit ‘this’ parameter from ‘const FixedLengthFieldsRecord*’ to ‘FixedLengthFieldsRecord*’
FixedLengthRecordFile.cpp:213:1: warning: control reaches end of non-void function [-Wreturn-type]
什么是错误的原因是什么?我在代码中看不到任何错误。此外,我还有另外两个类似的函数(写),它工作得很好。
而且请在课堂上展示功能的声明。 –
在执行'FixedLengthRecordFile :: write'之前,你有'FixedLengthFieldsRecord :: write'原型吗? – Kupto