我有以下代碼:爲什麼發生異常時不顯示整數?
int main()
{
int i = 0;
cout << i; //why is i not printed even though it is before the exception?
int j = 1/i; //divide by 0
j++;
cout << i << j;
return 0;
}
爲什麼i
不打印?它應該被打印,因爲它在異常發生之前。
但沒有打印,我只是得到例外。
任何想法?
[除以0的除法不會引發異常](http://stackoverflow.com/questions/6121623/catching-exception-divide-by-zero)。所以程序很可能會運行完成,你會看到輸出。 – PaulMcKenzie