1 <span class="co2">#include <iostream></span>
2 using namespace std<span class="sy0">;</span>
4 <span class="kw4">int</span> f<span class="br0">(</span><span class="kw4">int</span> x<span class="br0">)</span>
5 <span class="br0">{</span>
6 <span class="kw1">if</span><span class="br0">(</span>x <span class="sy0"><</span> 0<span class="br0">)</span> throw <span class="nu0">0</span><span class="sy0">;</span>
7 <span class="kw1">return</span> <span class="nu0">1</span><span class="sy0">;</span>
8 <span class="br0">}</span>
10 <span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
11 <span class="br0">{</span>
12 try <span class="br0">{</span>
13 <a href="http://www.opengroup.org/onlinepubs/009695399/functions/cout.html"><span class="kw3">cout</span></a> <span class="sy0"><<</span> f<span class="br0">(</span>0<span class="br0">)</span> <span class="sy0"><<</span> endl<span class="sy0">;</span>
14 <a href="http://www.opengroup.org/onlinepubs/009695399/functions/cout.html"><span class="kw3">cout</span></a> <span class="sy0"><<</span> f<span class="br0">(</span><span class="sy0">-</span>1<span class="br0">)</span> <span class="sy0"><<</span> endl<span class="sy0">;</span>
15 <span class="br0">}</span> catch<span class="br0">(</span><span class="kw4">int</span> e<span class="br0">)</span> <span class="br0">{</span>
16 <a href="http://www.opengroup.org/onlinepubs/009695399/functions/cout.html"><span class="kw3">cout</span></a> <span class="sy0"><<</span> <span class="st0">"catch "</span> <span class="sy0"><<</span> e <span class="sy0"><<</span> endl<span class="sy0">;</span>
17 <span class="br0">}</span>
18 <span class="br0">}</span>