Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class MyException : std::exception {
- std::string msg;
- public:
- MyException(std::string s) : msg(s) {
- }
- const char *what() {
- return msg.c_str();
- }
- };
- int main() {
- try {
- throw MyException("hello!");
- } catch (std::exception &e) {
- std::cerr << e.what() << std::endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment