View Full Version : exception mechanism
guchangyuan
8th August 2009, 04:16
i write like this,
try
{
int i = 5;
int j = i / 0;
}
catch (...)
{
qDebug("divided by zero.");
}
use qt in win32, but the catch can't catch the error, direct popup the microsoft's "sorry for inconvenice..." error box.
anyone can teach me a method to solve this.
can qt do it like mfc?
caduel
8th August 2009, 08:15
The C++ standard does not guarantee that an exception is thrown on a division by 0. You may need to read up on your compiler's options, maybe it is possible to configure it such that an exception is thrown in that case.
But "usually" your app will just crash.
See http://www.jdl.co.uk/briefings/divByZeroInCpp.html
HTH
guchangyuan
10th August 2009, 04:57
The C++ standard does not guarantee that an exception is thrown on a division by 0. You may need to read up on your compiler's options, maybe it is possible to configure it such that an exception is thrown in that case.
But "usually" your app will just crash.
See http://www.jdl.co.uk/briefings/divByZeroInCpp.html
HTH
thank you for you reply, is there any way like in mfc, try, catch(...), can catch all the error.and give the tips, it makes dubug easy.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.