如何解决此构建错误:UNIX 下 C++ 中的“没有匹配的调用函数”?
我收到以下构建错误:
unixserver:Lab1> make
g++ -o LSL lab1.cpp Employee.cpp
lab1.cpp: In function int main():
lab1.cpp:199: error: no matching function for call to LinkedSortedList<Employee>::find(std::string&)
LinkedSortedList.cpp:137: note: candidates are: bool LinkedSortedList<Elem>::find(Elem) const [with Elem = Employee]
make: *** [main] Error 1
这是我的查找功能:
// Check to see if "value" is in the list. If it is found in the list,
// return true, otherwise return false. Like print(), this function is
// declared with the "const" keyword, and so cannot change the contents
// of the list.
template<class Elem>
bool LinkedSortedList<Elem>::find(Elem searchvalue) const {
if (head == NULL) {
return false;
} else {
while (head != NULL) {
LinkedNode<Elem>* pointer;
for (pointer = head; pointer != NULL; pointer = pointer->next)
if (pointer->value == searchvalue) {
return true;
}
}
}
return false;
}
这是在“public:”部分下的我的 LinkedSortedList.h 文件中:
bool find(Elem searchvalue) const;
这是缺少的代码:第 199 行
case 'S':
cout << "Save database to a file selected\n\n";
// TODO call function to save database to file
// File I/O Save to file
cout << "Please enter a file name: " << endl;
cin >> fileName;
{char* file = (char*) fileName.c_str();
writeFile(file, database);}
break;