title: C++ std::ifstream in constructor problem
body: <p>I've got a problem with this code:</p>
  
  <pre><code>#include &lt;fstream&gt;
  
  struct A
  {   
      A(std::ifstream input)
      {
          //some actions
      }
  };
  
  int main()
  {
      std::ifstream input("somefile.xxx");
  
      while (input.good())
      {
          A(input);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>G++ outputs me this:</p>
  
  <pre><code>$ g++ file.cpp
  file.cpp: In function `int main()':
  file.cpp:17: error: no matching function for call to `A::A()'
  file.cpp:4: note: candidates are: A::A(const A&amp;)
  file.cpp:6: note:                 A::A(std::ifstream)
  </code></pre>
  
  <p>After changing it to this it compile (but that is not solving the problem):</p>
  
  <pre><code>#include &lt;fstream&gt;
  
  struct A
  {   
      A(int a)
      {
          //some actions
      }
  };
  
  int main()
  {
      std::ifstream input("dane.dat");
  
      while (input.good())
      {
          A(5);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Can someone explain me what's wrong and how to fix it? Thanks.</p>