[ create a new paste ] login | about

Link: http://codepad.org/pZv9VgiX    [ raw code | output | fork ]

aaronla - C++, pasted on Mar 16:
    #include <iostream>
    using namespace std;

    void f() {
        throw 1;
    }
    void g() {
        // will look at int and char exceptions
        try { 
            throw;
        } catch (int xyz){
            cout << "caught int " << xyz << "\n";
        } catch (char xyz){
            cout << "caught char " << xyz << "\n";
        }
    }
    void h() {
        try {
            f();
        } catch (...) {
            // use g as a common exception filter
            g();
        }
    }
    int main(){
        try {
            h();
        } catch (...) {
            cout << "some other exception.\n";
        }
    }


Output:
1
caught int 1


Create a new paste based on this one


Comments: