title: Assign a reference to a fstream object to an existing fstream object
body: <p>I am working on a spell checker program . </p>
  
  <pre><code>public:
  SpellChecker(fstream&amp; fileName)
      :dic("wordEn.txt"),
      fileToSpell(fileName),
      appendbleChanges()
  {
  }
  
  private:
      Dictionary dic;//dictionary
      fstream&amp; fileToSpell;
      stringMap appendbleChanges;//map that save changes to the words in the file
  </code></pre>
  
  <p>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 . </p>
  
  <pre><code>void SpellChecker::setFile(fstream&amp; fileName)
  {
      appendbleChanges.clear();//clear the previous history 
  
      fileToSpell.open(fileName);//wrong!!
  }
  </code></pre>
  
  <p>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 ... </p>