Я изучаю C++, и у меня возникают некоторые проблемы, когда я пытаюсь использовать String в методе ifstream, например:
string filename;
cout << "Enter the name of the file: ";
cin >> filename;
ifstream file ( filename );
Вот полный код:
// obtaining file size
#include <iostream>
#include <fstream>
using namespace std;
int main ( int argc, char** argv )
{
string file;
long begin,end;
cout << "Enter the name of the file: ";
cin >> file;
ifstream myfile ( file );
begin = myfile.tellg();
myfile.seekg (0, ios::end);
end = myfile.tellg();
myfile.close();
cout << "File size is: " << (end-begin) << " Bytes.\n";
return 0;
}
А вот и ошибка Eclipse, x перед методом:
no matching function for call to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(std::string&)'
Но когда я пытаюсь скомпилировать в Eclipse, перед методом ставится x, что указывает на ошибку в синтаксисе, но что не так в синтаксисе? Спасибо!