Error checking simple Calculator
<p>I'm having a little bit of trouble error checking if the user divides by 0.
if the user requests a division by 0 the result string should indicate that it is illegal to perform a divide by zero. it should look like this:</p>

<blockquote>
  <p>Your operation is division: 6/0   Illegal Operation!</p>
</blockquote>

<p>However I have no clue how to get it to look like that. so far I can only <code>std::cout</code> a "this is illegal" message, but the output ends up looking like this:</p>

<blockquote>
  <p>This is illegal!Your operation is : 6 / 0=-858993460</p>
</blockquote>

<p>I've also tried to set results to a different string in the else statement. It just ignores it.</p>

<p>how would I end up coding this?</p>

<pre><code>void Simplecalc::setOperation(char oper, int op1, int op2)
{
operation = oper;
number1 = op1;
number2 = op2;
    if(operation == '+')
    {
    answer = number1 + number2;
    type ="addition";
    }
    else if(operation =='-')
    {
        answer = number1 - number2;
        type ="subtraction";
    }
    else if(operation =='*')
    {
        answer = number1 * number2;
        type = "multiplication";
    }
    else if(operation =='/')
    {
        if(number2 != 0)
    {
         answer = number1/number2;
         type = "division";
    }
   else
       {
     cout&lt;&lt;"this is illegal!";

        }


    }

    else if(operation =='%')
    {
        answer = number1%number2;
        type ="modulus";
    }


}

string Simplecalc::getResults()
{

stringstream ss;
    ss &lt;&lt;"Your operation is "&lt;&lt;type&lt;&lt;": "&lt;&lt;number1&lt;&lt;" "&lt;&lt;operation&lt;&lt;" "&lt;&lt;number2&lt;&lt;"="    
    &lt;&lt;answer&lt;&lt;"\n";
results =ss.str();


   return results;
}
</code></pre>
