#include "dictionary.h" Dictionary::Dictionary() { size = 0; string badWord, goodWord; // Misspelled and correctly spelled word // Attempt to open file; quit if unsuccessful ifstream data("words.txt"); if (!data) cout<<"Error opening words.txt"<> badWord >> goodWord; while (badWord != ".") { list[size].setWrongWord(badWord); list[size].setRightWord(goodWord); size++; data >> badWord >> goodWord; } } string Dictionary::correctWord(string token) { int k = 0; //used to get the index of the element in the word list which matches our query while (k < size && list[k].getWrongWord() != token) k++; if (k < size) //if we've found a match.. return list[k].getRightWord(); else return token; }