[ create a new paste ] login | about

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

C++, pasted on Feb 18:
#include <iostream>
#include <string>
using namespace std;

string func(int choise){
    try{
        if( choise == 1 )
            throw "some throw";
        else
        if( choise == 2 )
            return "try return";
    }
    catch(const char * msg){
        return msg;
    }
    return "normal return";
}

int main(){
    cout<<func(0)<<endl;
    cout<<func(1)<<endl;
    cout<<func(2)<<endl;
    return 0;
}


Output:
1
2
3
normal return
some throw
try return


Create a new paste based on this one


Comments: