loo*_*oop 0 c++ windows exception try-catch visual-c++
这会崩溃:
try
{
if(1)
throw;
}
catch(...)
{
printf("hi");
}
Run Code Online (Sandbox Code Playgroud)
我以为我能做到,但我猜不是.当您不需要任何信息时,正确的投掷方式是什么?
"裸投"重新抛出已经被捕获的异常.如果没有什么可以重新抛出,那么效果不好.
你可以扔掉任何东西,比如throw "Error!";,即使它不太有用.你可以尝试
if (x == 1)
throw std::runtime_error("x == 1 is not a good value here")`.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
359 次 |
| 最近记录: |