title: C++ Exceptions and Inheritance from std::exception
body: <p>Given this sample code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdexcept&gt;
  
  class my_exception_t : std::exception
  {
  public:
      explicit my_exception_t()
      { }
  
      virtual const char* what() const throw()
      { return "Hello, world!"; }
  };
  
  int main()
  {
      try
          { throw my_exception_t(); }
      catch (const std::exception&amp; error)
          { std::cerr &lt;&lt; "Exception: " &lt;&lt; error.what() &lt;&lt; std::endl; }
      catch (...)
          { std::cerr &lt;&lt; "Exception: unknown" &lt;&lt; std::endl; }
  
      return 0;
  }
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>Exception: unknown
  </code></pre>
  
  <p>Yet simply making the inheritance of <code>my_exception_t</code> from <code>std::exception</code> <code>public</code>, I get the following output:</p>
  
  <pre><code>Exception: Hello, world!
  </code></pre>
  
  <p>Could someone please explain to me why the type of inheritance matters in this case? Bonus points for a reference in the standard.</p>