fork download
  1. #include <iostream>
  2.  
  3. class MathException : std::exception
  4. {
  5. public:
  6. MathException(std::string &&whatStr) noexcept : whatStr(std::move(whatStr)) { }
  7. MathException(const std::string &whatStr) noexcept : whatStr(whatStr) { }
  8. ~MathException() noexcept;
  9.  
  10. const char* what() const noexcept override;
  11.  
  12. private:
  13. std::string whatStr;
  14. };
  15.  
  16. const char* MathException::what() const noexcept
  17. {
  18. return whatStr.c_str();
  19. }
  20.  
  21. int main()
  22. try
  23. {
  24. true ? throw MathException("Parse Error") : 1;
  25. }
  26. catch(...)
  27. {
  28.  
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/7NhO2E/ccLwHgxD.o: In function `main':
prog.cpp:(.text.startup+0x39): undefined reference to `vtable for MathException'
prog.cpp:(.text.startup+0x3e): undefined reference to `MathException::~MathException()'
prog.cpp:(.text.startup+0x43): undefined reference to `typeinfo for MathException'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty