[c++] throw-catch问题1

TEST 1

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    try{
        try {throw "help...";}
        catch(int){cout<<"1in fc...int hanlder"<<endl;}
        try {throw "help...";}
        catch(char const*){cout<<"2in fc...int hanlder"<<endl;}
    }
    catch(...)
    {
        cout<<"here"<<endl;
    }
    return 0;
}

Output

here

TEST 2

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    try{
        //try {throw "help...";}
        //catch(int){cout<<"1in fc...int hanlder"<<endl;}
        try {throw "help...";}
        catch(char const*){cout<<"2in fc...int hanlder"<<endl;}
    }
    catch(...)
    {
        cout<<"here"<<endl;
    }
    return 0;
}

Output

2in fc...int hanlder
发布了51 篇原创文章 · 获赞 5 · 访问量 4213

猜你喜欢

转载自blog.csdn.net/qq_43519498/article/details/90703104
今日推荐