title: "Incomplete type"-error when trying to open ifstream
body: <p>I am trying to read a file in C++, using the built in compiler of Visual Studio 2019. Following some examples I found, I try this:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
      ifstream file("test.txt");
      string input = "";
      while (file &gt;&gt; input) {
          std::cout &lt;&lt; input;
      }
      std::cout &lt;&lt; "Hello World!\n";
  }
  </code></pre>
  
  <p>However, while compiling Visual Studio shows the error <code>incomplete type is not allowed</code>. The output window shows <code>error C2079: 'file' uses undefined class 'std::basic_ifstream&lt;char,std::char_traits&lt;char&gt;&gt;'</code>.</p>
  
  <p>Following <a href="https://stackoverflow.com/questions/50841816/c-ifstream-has-incomplete-type">this thread</a> like so:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>ifstream file;
  file.open("test.txt");
  </code></pre>
  
  <p>gives me the same error.</p>
  
  <ol>
  <li>What does the error mean?</li>
  <li>How do I fix it?</li>
  </ol>