title: Put A String In A ifstream Method
body: <p>I'm learning C++ and i'm getting some troubles when i'm trying to use a <em>String</em> in a <em>ifstream</em> method, like this:</p>
  
  <pre><code>string filename;
  cout &lt;&lt; "Enter the name of the file: ";
     cin &gt;&gt; filename;
  ifstream file ( filename );
  </code></pre>
  
  <p>Here is the full code:</p>
  
  <pre><code>// obtaining file size
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main ( int argc, char** argv )
  {
      string file;
      long begin,end;
      cout &lt;&lt; "Enter the name of the file: ";
         cin &gt;&gt; file;
      ifstream myfile ( file );
      begin = myfile.tellg();
      myfile.seekg (0, ios::end);
      end = myfile.tellg();
      myfile.close();
      cout &lt;&lt; "File size is: " &lt;&lt; (end-begin) &lt;&lt; " Bytes.\n";
  
      return 0;
  }
  </code></pre>
  
  <p>And here is the error of the Eclipse, the <strong>x</strong> before the method:</p>
  
  <pre><code>no matching function for call to `std::basic_ifstream&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ifstream(std::string&amp;)'
  </code></pre>
  
  <p>But when i try to compile in Eclipse it put an <strong>x</strong> before the method, that indicates an error in the syntax, but what is wrong in the syntax? Thanks!</p>