Doxybook Example
exception.h
Go to the documentation of this file.
1 #ifndef EXAMPLE_EXCEPTION_H
2 #define EXAMPLE_EXCEPTION_H
3 
4 #include <exception>
5 #include <string>
6 
15 namespace example {
19  class CustomException : public std::exception {
20  public:
21  CustomException(const std::string& msg):std::exception(),msg(msg){
22 
23  }
24 
25  virtual const char* what() const throw() {
26  return msg.c_str();
27  }
28 
29  private:
30  std::string msg;
31  };
32 
36  class NumericException : public std::exception {
37  public:
38  NumericException(const std::string& msg):std::exception(),msg(msg){
39 
40  }
41 
42  virtual const char* what() const throw() {
43  return msg.c_str();
44  }
45 
46  private:
47  std::string msg;
48  };
49 }
50 
51 #endif
CustomException(const std::string &msg)
Definition: exception.h:21
NumericException(const std::string &msg)
Definition: exception.h:38
virtual const char * what() const
Definition: exception.h:25
Definition: animal.h:31
Definition: exception.h:36
virtual const char * what() const
Definition: exception.h:42
Definition: exception.h:19