title: C++ - Compilation error with Error class that inherit from std::exception
body: <p>Here is my Error class to handle errors with try &amp; catch :</p>
  
  <pre><code>#include &lt;stdexcept&gt;
  #include &lt;string&gt;
  
    class Error : public std::exception
      {
      public:
        Error(const std::string&amp;) throw();
        ~Error() throw();
        const char*   what() const throw();
      private:
        std::string           _msg;
      };
  </code></pre>
  
  <p>And the cpp file :</p>
  
  <pre><code>#include "Error.hpp"
  
  Error::Error(const std::string&amp; msg) throw()
    : _msg(msg)
  {
  }
  
  Error::~Error() throw()
  {
  }
  
  const char*     Error::what() const throw()
  {
    return (_msg.c_str());
  }
  </code></pre>
  
  <p>And I have this errors while compiling:</p>
  
  <pre><code>main.o:(.gcc_except_table+0x34): undefined reference to `typeinfo for Error'
  MailBox.o: In function `MailBox::MailBox(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)':
  MailBox.cpp:(.text+0x245): undefined reference to `Error::Error(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  MailBox.cpp:(.text+0x268): undefined reference to `Error::~Error()'
  MailBox.cpp:(.text+0x270): undefined reference to `typeinfo for Error'
  MailBox.cpp:(.text+0x2f0): undefined reference to `Error::Error(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  MailBox.cpp:(.text+0x313): undefined reference to `Error::~Error()'
  MailBox.cpp:(.text+0x31b): undefined reference to `typeinfo for Error'
  MailBox.cpp:(.text+0x3d6): undefined reference to `Error::Error(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  MailBox.cpp:(.text+0x3f9): undefined reference to `Error::~Error()'
  MailBox.cpp:(.text+0x401): undefined reference to `typeinfo for Error'
  MailBox.cpp:(.text+0x452): undefined reference to `Error::Error(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  MailBox.cpp:(.text+0x475): undefined reference to `Error::~Error()'
  MailBox.cpp:(.text+0x47d): undefined reference to `typeinfo for Error'
  MailBox.cpp:(.text+0x50a): undefined reference to `Error::Error(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  MailBox.cpp:(.text+0x52d): undefined reference to `Error::~Error()'
  MailBox.cpp:(.text+0x535): undefined reference to `typeinfo for Error'
  MailBox.cpp:(.text+0x6af): undefined reference to `Error::Error(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  MailBox.cpp:(.text+0x6d2): undefined reference to `Error::~Error()'
  MailBox.cpp:(.text+0x6da): undefined reference to `typeinfo for Error'
  MailBox.cpp:(.text+0x854): undefined reference to `Error::Error(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  MailBox.cpp:(.text+0x877): undefined reference to `Error::~Error()'
  MailBox.cpp:(.text+0x87f): undefined reference to `typeinfo for Error'
  MailBox.cpp:(.text+0x923): undefined reference to `Error::Error(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  MailBox.cpp:(.text+0x946): undefined reference to `Error::~Error()'
  MailBox.cpp:(.text+0x94e): undefined reference to `typeinfo for Error'
  MailBox.cpp:(.text+0x9b6): undefined reference to `Error::Error(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  MailBox.cpp:(.text+0x9d9): undefined reference to `Error::~Error()'
  MailBox.cpp:(.text+0x9e1): undefined reference to `typeinfo for Error'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I've already used this Error class for another project, and it worked well. I don't understand why here it doesn't work.</p>