我认为这段代码是否正确:
try
{
Screen->Cursor = crHourGlass;
try
{
throw Exception("error!");
}
catch(Exception& e)
{
Application->MessageBox(UnicodeString(e.Message).c_str(), L"Error", MB_OK);
}
}
__finally
{
Screen->Cursor = crDefault;
}
实际上与这个相同,__finally 在这里没有任何作用,因为在这两种情况下,Screen->Cursor = crDefault 都会被执行?
Screen->Cursor = crHourGlass;
try
{
throw Exception("error!");
}
catch(Exception& e)
{
Application->MessageBox(UnicodeString(e.Message).c_str(), L"Error", MB_OK);
}
Screen->Cursor = crDefault;
最佳答案
不,因为您只捕获 Exception
类型的异常。如果发生其他异常,则 Screen->Cursor = crDefault 将不会在第二版代码中执行。
关于c++ - try catch __finally 在 C++ Builder 中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35728957/