title: Stringstream vs. type casting in C++
body: <p>How does using <code>stringstream</code> to extract an integer value from a string differ from simply using explicit value casting to change the type?</p>
  
  <p>Example:</p>
  
  <pre><code>string a = "1234";
  int x;
  x= int (a);
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>string a = "1234";
  int x;
  stringstream (a) &gt;&gt; x;
  </code></pre>