Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <exception>
- #include <iostream>
- #include <string>
- class CCoolException : public std::exception{
- public:
- explicit CCoolException(const char* _description): description(_description){}
- ~CCoolException(){std::cout << "~CCoolException" << std::endl;}
- virtual char const* what() const override { return description.c_str();}
- private:
- std::string description;
- };
- void f (){
- throw CCoolException("That's cool");
- }
- void g() {
- throw std::exception("Not cool");
- }
- int main(){
- try{
- f();
- g();
- } catch (std::exception& e) {
- std::cout << e.what() << std::endl;
- return 1;
- } catch (...){
- std::cout << "Three dots" << std::endl;
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement