Я встретив ошибку во время компиляции с следующим выводом:C++: функция не может быть перегружена
$ g++ -ggdb `pkg-config --cflags opencv` -o `basename main.cpp .cpp` main.cpp StringMethods/StringMethods.cpp `pkg-config --libs opencv` -std=c++0x
In file included from main.cpp:2:0:
VideoFile.hpp:32:10: error: ‘bool VideoFile::fileExists(const string&)’ cannot be overloaded
bool fileExists(const std::string & path)
^
VideoFile.hpp:15:10: error: with ‘bool VideoFile::fileExists(const string&)’
bool fileExists(const std::string & path);
Однако, я не вижу, как эта ошибка имеет смысл, потому что у меня есть только объявление функции, которые я непосредственно скопированный и вставлен при написании определения.
class VideoFile
{
private:
std::string filePath;
bool fileExists(const std::string & path);
public:
VideoFile(const std::string & path)
:filePath(path)
{
filePath = StringMethods::trim(path);
if (!fileExists(filePath))
throw std::runtime_error("The file: " + filePath + " was not accessible");
}
~VideoFile()
{
}
bool fileExists(const std::string & path)
{
std::ifstream file(path);
return file.good();
}
};