这是涉及的两个功能:
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]
错误的原因是什么?我在代码中没有看到任何错误。此外,我还有另外两个类似的功能(写),它工作得很好。