title: Writing custom exceptions in C++
body: <p>I am coming from a Ruby and Java background and have recently begun exploring C++.</p>
  
  <p>While my initial attempts at creating custom exceptions by simply subclassing exception class failed with obscure, I found the following example posted on a site:</p>
  
  <pre><code>class Exception : public exception
  {
  public:
    Exception(string m="exception!") : msg(m) {}
    ~Exception() throw() {}
    const char* what() const throw() { return msg.c_str(); }
  
  private:
    string msg;
  };
  </code></pre>
  
  <p>My understanding of semantics of C++ is not very mature at the moment, and I would like to have a better understanding of what is going on here.</p>
  
  <p>In the statement <code>const char* what() const throw()</code> what does the part <code>const throw()</code> do, and what kind of programming construct is it?</p>
  
  <p>Also, what is the purpose and intent of <code>throw()</code> in the destructor specification <code>~Exception()</code> and why do I need to have a destructor specification although I don't need it do something in particular? Shouldn't the <code>destructor</code> inherited from exception be sufficient?</p>