|
Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006
C + + exception handling problems [code]
#include "Iostream>
#include "Exception>
Using namespace std;
Void terminator () (
Cout "" "I 'll be back!" "" endl;
Exit (0);
}
Void (*old_terminate) () = set_terminate (terminator);
14.00 -- Botch
Public :
14.00 Fruit {};
Void f () (
Cout "" "Botch : : f ()" "" endl;
Throw Fruit ();
}
~Botch () (Throw 'c'; )
};
Int main () (
Try (
Botch 1997a
EV ();
) Catch (. . . ) (
Cout "" "inside catch (. . . ) "" "Endl;
}
Return 0
}
[/code]
My question :
[code]catch (. . . ) {}[/code] Can not capture all the anomalies? However, in the process capture Lane Why not? |
May not support anomaly. |
Abnormal, in the try block the establishment of the structure function analysis of all the objects will automatically be deployed. Obviously, if the destructor function within another unusual occurrence, and was not unusual to deal with the case, Std : : terminate () function will be deployed, resulting in the proceedings. Exception handling this break. Therefore, the analysis of abnormal structure function analysis of the structure function of time must be captured and not to let the structure function analysis of anomalies spread to the outside world. |
Black dished out the destructor is a very unusual design : :
You
{
Botch 1997a
EV ();
}
Swap alternative
Botch 1997a
EV ();
If the compiler supports such anomalies can capture the
|
-->
Exceptional C + + reference [Sutter00] Item 16, which discusses "That Destructors and Why They Throw 'Ampere Evil. "
I do not know how many. : Oops : |
-->
As it is known structure function analysis of the problems in the design, why not the right remedy, but to some irrelevant changes? |
-->
I have told him that the design is very bad.
However, the purpose is to capture the abnormal people, I can not catch ah, we can only provide a good idea of |
-->
You ideas effectively? |
VC I dare not guarantee, of course, effective gcc |
| |