Tuesday 15 March 2011

exception handling - In C++, is there a difference between “throw” and “throw ex”? -


I also want to ask, but this time about C ++

What is the difference between C ++

  Try {/ * to capture some code here (Myexception and prior) {ex EX;} / / bus Do not throw  

and

  try {/ * some code is here /} (my expansion and pre) {throw;} // pre < / Code> 

Is it simply stack trace (which is not standard in C ++ or Java in any case in C ++)?

(If it makes a difference, then I use MSVS 2008.)

Throw; The same exception recovers the object while throwing it ; throws a new exception, it does not make any difference other than the reasons for the performance of creating a new exception object. If you have an exception hierarchy where there are some other exception categories that are derived from the MyException class and throwing exceptions you thrown DerivedClassException; hold it it (MyException & amp;) . Now if you modify this captured exception object and have it throw; If the exception object is reused using then DerivedClassException will be. If you throw ; Object slice is done and new thrown exception type MyException .


No comments:

Post a Comment