try..catch之后的命令不起作用

use*_*490 2 c++ mfc

我有一个try..catch的方法.结构是这样的:

try
{
 commands...

}
catch(...)
{
    ERROR(...);
}
if(m_pDoc->m_bS = FALSE ) // Check here if AutoLogout event occurred.
    StartCollect();
}
Run Code Online (Sandbox Code Playgroud)

该程序不会进入catch部分,但它也不会进入if语句.可能是什么问题?为什么程序没有转到if语句?

谢谢

Mar*_*k B 6

你的if陈述几乎肯定是错的.你分配FALSEbSilenClose,然后检查是否它(假)为真,这将导致你的身体if永远不会执行.在C++中,对等式的测试是==.此外,正如@Martin York指出的那样,尾随;将被视为你的if的主体.事实上,下面的大括号中的代码每次都应该执行.

if(m_pDoc->m_bSilenClose = FALSE );
                         ^       ^^^^ This should not be there. (Empty statement after if)
                         ^
                         ^ Assigning FALSE (should be == to test)
                           Condition always FALSE (thus never executes empty statement.
Run Code Online (Sandbox Code Playgroud)