今天写了一些 关于 异常处理的东东,提交的时候居然网络不能用全丢了,没办法了,我就贴一点东西上来了
 
catch( exPoint p )
{
   // do something
   throw;
}
and an exception object of type exVertex derived from exPoint. The two types match and the catch clause block becomes active. What happens with p ?
  • p is initialized by value with the exception object the same as if it were a formal argument of a function. This means a copy constructor and destructor, if defined or synthesized by the compiler, are applied to the local copy.
  • Because p is an object and not a reference, the non-exPoint portion of the exception object is sliced off when the values are copied. In addition, if virtual functions are provided for the exception hierarchy, the vptr of p is set to exPoint's virtual table; the exception object's vptr is not copied.
What happens when the exception is rethrown? Is p now the object propagated or the exception object originally generated at the throw site? p is a local object destroyed at the close of the catch clause. Throwing p would require the generation of another temporary. It also would mean losing the exVertex portion of the original exception. The original exception object is rethrown; any modifications to p are discarded.