title: I cant' seem to catch this exception in C++
body: <p>For some reason the program exits when executed while testing the handling of an exception. This is the class im using as the exception recipient</p>
  <pre><code>#ifndef _BADALLOC
  #define _BADALLOC
  #include &lt;cstring&gt;
  using namespace std;
  class badalloc{
  private:
      char* Message;
      double Number;
      
  public:
      explicit badalloc(char* M=&quot;Error&quot;,const int &amp; N=0)  {strcpy(Message,M); Number=N;}
      char* what () const {return Message;}
  };
  #endif
  </code></pre>
  <p>this is the function member of another class that generates the exception</p>
  <pre><code>void ContoCorrente::Prelievo ( const double &amp; P) throw ( badalloc )
  {
  if(P&gt;0)
  { 
      throw (badalloc (&quot;ERROR 111XX&quot;,P));
  } ...
  </code></pre>
  <p>test main :</p>
  <pre><code>try
  {
  c2.Prelievo(20);
  
  }
  catch ( badalloc e)
  {
      cout&lt;&lt;e.what()&lt;&lt;endl;
  }
  </code></pre>
  <p>output:</p>
  <hr />
  <p>Process exited after 1.276 seconds with return value 3221225477
  Press any key to continue . . .</p>
  <p>i tried defining the badalloc object to throw as &quot;const&quot; but to no use. any ideas?</p>