title: Good input validation loop using cin - C++
body: <p>I'm in my second OOP class, and my first class was taught in C#, so I'm new to C++ and currently I am practicing input validation using cin. So here's my question:</p>
  
  <p>Is this loop I constructed a pretty good way of validating input? Or is there a more common/accepted way of doing it?</p>
  
  <p>Thanks!</p>
  
  <p>Code:</p>
  
  <pre><code>int taxableIncome;
  int error;
  
  // input validation loop
  do
  {
      error = 0;
      cout &lt;&lt; "Please enter in your taxable income: ";
      cin &gt;&gt; taxableIncome;
      if (cin.fail())
      {
          cout &lt;&lt; "Please enter a valid integer" &lt;&lt; endl;
          error = 1;
          cin.clear();
          cin.ignore(80, '\n');
      }
  }while(error == 1);
  </code></pre>