What happens when I throw an exception?

后端 未结 2 1537
小鲜肉
小鲜肉 2021-02-15 02:56

I have some technical questions. In this function:

string report() const {
    if(list.begin() == list.end()){
        throw \"not good\";
    }
    //do somethi         


        
2条回答
  •  再見小時候
    2021-02-15 03:52

    If you throw an exception, all functions will be exited back to the point where it finds a try...catch block with a matching catch type. If your function isn't called from within a try block, the program will exit with an unhandled exception.

    Check out https://isocpp.org/wiki/faq/exceptions for more info.

提交回复
热议问题