Does it make sense to catch exceptions in the main(…)?

前端 未结 7 775
攒了一身酷
攒了一身酷 2020-12-16 17:50

I found some code in a project which looks like that :

int main(int argc, char *argv[])
{
  // some stuff

 try {
  theApp.Run();
 } catch (std::exception&a         


        
7条回答
  •  再見小時候
    2020-12-16 18:14

    Why do you say that the exception would be printed? This is not the typical behavior of the C++ runtime. At best, you can expect that its type gets printed.

    In addition, this program leaves a "failure" status, whereas an exception might cause a termination-through-abort status (i.e. with a signal indicated in the exit code).

提交回复
热议问题