title: C++ stringstreams with std::hex
body: <p>I am looking into code at work. I am having following code. In following code what is the meaning of the last statement?</p>
  
  <pre><code>bOptMask = true;
  std::string strMask;
  strMask.append(optarg);
  std::stringstream(strMask) &gt;&gt; std::hex &gt;&gt; iMask &gt;&gt; std::dec;
  </code></pre>
  
  <p>In addition to the above question: I have string input and I need to know how to convert it to an integer using C++ streams as above instead of <code>atoi()</code>.</p>
  
  <p>The problem I am facing is if I give input</p>
  
  <pre><code>strOutput.append(optarg);
  cout &lt;&lt; "Received option for optarg is " &lt;&lt; optarg &lt;&lt; endl;
  std::stringstream(strOutput) &gt;&gt; m_ivalue ;
  cout &lt;&lt; "Received option for value is " &lt;&lt; m_ivalue &lt;&lt; endl;
  </code></pre>
  
  <p>For the above code, if I am running with argument "a" I am having an output with first line as "a" and a second line output as 0. I am not sure why, can any one explain?</p>