OK – below is my Dictionary class – hope that it makes sense and I haven’t sent you too much superfluous stuff. All of this code works inside the main() function so I am guessing it is my passing of parameters that is my problem.
class Dictionary
{
private:
Word dictionary;
public:
void loadDictionary(Dictionary*);
int getMaxNoOfWords();
};
void Dictionary::loadDictionary(Dictionary* d)
{
ifstream dictionaryFile; // iostream input object
dictionaryFile.open(“c:/users/fee/dictionary.txt”); // open dictionary file
string word, definition, wordType, blankLine; // variables to hold dictionary elements
if (!dictionaryFile.good())
{
// File not found or could not be opened
cout << “File could not be opened”;
return; // close program if file open fails
}
else
{
// File found – proceed
cout << “Welcome to CSP2104 Object Oriented Programming with C++ \n\t\t Assignment Part 1\n\n”;
cout << “\tWord Play with Supplied Dictionary (dictionary.txt)\n\n”;
cout << “Loading Dictionary….” << endl;
int wordTally = 0; // to establish number of words
for (int i = 0; i <
DICTIONARY_SIZE; i++) // ##can’t resolve eof yet** still to be done
{
getline(dictionaryFile, word); //————————————————-
getline(dictionaryFile, definition); // Get dictionary elements
getline(dictionaryFile, wordType); //—————————————————
getline(dictionaryFile, blankLine); // Skip blank line after each record
dictionary.setWord(word); //————————————————-
dictionary.setDefinition(definition); // Set dictionary elements in array
dictionary.setWordType(wordType); // ————————————————-
wordTally++; // increment word counter
}
dictionaryFile.close(); //housekeeping – close file.
}
}
int Dictionary::getMaxNoOfWords()
{
return wordTally;
}
Sorry that’s probably more than you need
I thought I understood that to call the loadDictionary function you would use loadDictionary(&dictionary);
Thank you :)