fork download
  1. #include <iostream>
  2. using namespace std;
  3. class Exception
  4. {
  5. public:
  6. static void eThrowException(const Exception& error)
  7. {
  8. cout<< error.what() <<endl;
  9. }
  10.  
  11. virtual const char* what() const;
  12. };
  13.  
  14. class ThingThatUsesTheExceptions
  15. {
  16. private:
  17. struct HereBeTheError : public Exception { const char* what() const { return "Yarrrrr me matey"; } };
  18.  
  19. protected:
  20. void cFunctionThatTriggersAnError()
  21. {
  22. Exception::eThrowException(HereBeTheError()); //This is where the error occurs.
  23. }
  24. };
  25. int main() {
  26. // your code goes here
  27. return 0;
  28. }
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
Standard output is empty