Catching exception without having to throw
<p>I am new to C++ and I come from a Delphi scenario, in which I was able to catch exceptions even without having to declare an explicit <code>throw</code>. Look at here:</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;exception&gt;

int main() {

 try {

  int c;
  std::cin &gt;&gt; c;

 } catch(...) {

  std::cerr &lt;&lt; "Warning!" &lt;&lt; std::endl;
  char xz; std::cin &gt;&gt; xz;
  return 1;

 }

 char z; std::cin &gt;&gt; z;
 return 0;

}

//I return 1 because UNIX OS cares about this, a return != 0 means that Huston we have a problem
</code></pre>

<p>I have seen around that some exception (such as division by zero) aren't automatically caught, so I have to create a <code>throw</code> by myself that will be caught for sure in my try-block.</p>

<p>If you look at the code above, when I first input <code>6.7</code> or <code>test</code> I should be able to see on the output <code>warning!</code>, but nothing. I am running on a Windows 10 machine.</p>

<p>I know that the <code>catch(...)</code> is the general one and gives me for sure the protection, but why isn't it catching the wrong input?</p>

<hr>

<p><strong>Note</strong>. I have mentioned Delphi above because if you look at the code below, I am able to catch the error.</p>

<pre><code>try

 a := StrToInt('6.78');              //conversion error [string-&gt;double], a is int
 ShowMessage('a is ' + a.ToString);

except
 on E: Exception do

 ShowMessage('Warning! &gt; ' + e.Message);
 //^ raises "Warning! &gt; '6.78' is not a valid integer value."

end;
</code></pre>

<p>Why cannot I produce the same effect with C++? I know that they are two different languages, but at first I'd say that delphi "treats" exceptions better. For example it catches automatically the division by zero (see below) while c++ doesnt.</p>

<pre><code>//this raises the "Division by zero" error.
a := 8 div StrToInt('0');
</code></pre>

<hr>

<p><strong>Conclusion</strong>. So the questions are: am I declaring the C++ <code>try-catch</code> correctly? Do I always have to use the <code>throw</code> to be <strong>sure</strong> that the error will be caught or I can omit it some times?</p>