PunCha

导航

What happend: Exception throws in the .ctor()?

1. If an exception was thrown in a type's .ctor(), then the class's destrutor wouldn't be called.
2. If a exception was catched in a try-catch block, all the well-constructed object will be destructed( destrutor method will be called) before enter the catch section:
try
{
  CFoo a;
  CFoo b;


  throw int();


  CFoo c;
}
catch(int& i)
{
  //----
}
the destrutor of a, b will be called except c.
3. Any created heap objects will be well-deleted before existing the try block even though an exception occurs.

posted on 2008-06-03 16:12  PunCha  阅读(147)  评论(0编辑  收藏  举报