cin stream error
<pre><code>int main()
{
    int i;

    if (cin &gt;&gt; i)
    {
        //ok
    }
    else
    {
        //error
        cin.setstate(std::ios_base::goodbit);
    }
}
</code></pre>

<p>Why can't I set <code>goodbit</code> through setstate() to clear out the <code>failbit</code> instead of cin.clear()?</p>
