Re[3]: __try __finnaly и классы
От: decaf  
Дата: 23.03.06 18:20
Оценка:
А>
А>MyClass *g_cl = NULL;

А>void foo()
А>{
А>    BOOL bOK = FALSE;
А>    g_cl = new MyClass();
А>    __try
А>    {
А>        if(g_cl->IsError())
А>            __leave;
А>            ...
А>            ...
А>        bOK = TRUE;
А>    }
А>    __finally
А>    {
А>        if(!bOK)
А>        {
А>            delete cl;
А>        }
А>    }
А>}
А>





class MyClass
{
public:
  bool is_error;
  MyClass()
   : is_error(false)
  {
    try
    {
      init();
    }
    catch(...)
    {
      is_error = true;
      uinit();
    }
  }
}

void main()
{
  MyClass* mc = new MyClass;
  if(mc->is_error)
    delete mc;
}
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.