How to deal with bad_alloc in c++?
<p>There is a method called <code>foo</code> that sometimes returns the following error:</p>

<pre><code>terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Abort
</code></pre>

<p>Is there a way that I can use a <code>try</code>-<code>catch</code> block to stop this error from terminating my program (all I want to do is return <code>-1</code>).<br>
If so, what is the syntax for it?</p>
