title: Error C2678: binary '<<' : no operator found which takes a left-hand operand of type 'const std::ofstream' (or there is no acceptable conversion)
body: <p>I am working on an <code>MFC Application</code> and have declared an <code>ofstream</code> object in a class header, the object is then initialized in the constructor and used in the other methods of the same class. I got the following error:</p>
  
  <blockquote>
    <p>Error C2678: binary '&lt;&lt;' : no operator found which takes a left-hand operand of type 'const std::ofstream' (or there is no acceptable conversion)</p>
  </blockquote>
  
  <p><em>I have searched about this issue and found many solutions i.e. there are some suggestions to:</em> </p>
  
  <ul>
  <li>Use <em><code>#include &lt;string&gt;</code></em></li>
  <li>Use <em><code>#include &lt;iostream&gt;</code></em></li>
  <li>Use <em><code>#include &lt;istream&gt;</code></em></li>
  </ul>
  
  <p>And some other information that I got is about when does this error occur. But all that I got doesn't fix my issue. Kindly have a look at my code:</p>
  
  <p><strong>CGroupComboBox.h :</strong></p>
  
  <pre><code>private:
      std::ofstream fptr;
  </code></pre>
  
  <p><strong>CGroupComboBox.cpp :</strong></p>
  
  <pre><code>//Constructor
  CGroupComboBox::CGroupComboBox()
      : m_dropdownListAutoWidth(true)
      , m_autocomplete(true)
      , m_selectionUndoByEscKey(true)
  {
      fptr.open("test.txt",std::ios::out); //Initialization of fptr
  }
  
  //Member Function
  int CGroupComboBox::FindString(int nStartAfter, LPCTSTR lpszString) const
  {
      fptr&lt;&lt;"I am FindString.\n"; //Trying to write something
  
      //Other Code
  }
  
  //Destructor
  CGroupComboBox::~CGroupComboBox()
  {
      //Other Code
  
      fptr.close();
  }
  </code></pre>
  
  <p>What am I doing wrong here?</p>