@gunnerfunner my file format is .cpp
@nuderobmonkey thank you, your input answers my question.
The only problem remaining is that I get an 3 errors that says:
In constructor 'Dictionary::Dictionary(const string&)':
[Error] could not convert 'iFile.std::basic_ifstream<_CharT, _Traits>::open<char, std::char_traits<char> >((& filename)->std::basic_string<_CharT, _Traits, _Alloc>::c_str<char, std::char_traits<char>, std::allocator<char> >(), (std::_Ios_Openmode)8u)' from 'void' to 'bool'
[Error] in argument to unary !
I am not sure what to do with.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Lexicon::Lexicon(const string& filename)
{
//lexicon= list<string>();
//Opens the file
ifstream iFile;
if(!iFile.open(filename.c_str()))
{
cerr<< "at Lexicon::Lexicon(): File couldn't oepn. \n";
return;
}
string words;
//Reads all word from file
while (iFile >> words)
{
addWord(words);
}
}
|