0

I am working on a spell checker program .

public:
SpellChecker(fstream& fileName)
    :dic("wordEn.txt"),
    fileToSpell(fileName),
    appendbleChanges()
{
}

private:
    Dictionary dic;//dictionary
    fstream& fileToSpell;
    stringMap appendbleChanges;//map that save changes to the words in the file

this is a simplified version of the class . creating dictionary is expensive , and i did not want the client to create it , so i made spell checker responsible to make it. then it was logical , to provide a setFile() function that enables spell checker class to work on new files, without creating a dictionary again .

void SpellChecker::setFile(fstream& fileName)
{
    appendbleChanges.clear();//clear the previous history 

    fileToSpell.open(fileName);//wrong!!
}

But i can't find a way to assign fileName to fileToSpell . assignment operator is deleted , and i am aware of using std::move() but it is not what i want to do , what if client wants to make further changes to the file after spellchecking ?? i can provide a getFile() function , but it is not nice to make client remember that ...

shayan
  • 361
  • 3
  • 14

0 Answers0