Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by NavBot (jp)

...

Code Block
bgColor#FFcccc
while (moreToDo) {
   SomeType *pst = getNextItem();
   try {
      pst->processItem();
   }
   catch (...) {
      // deal with exception
      throw;
   }
   delete pst;
}

...

Code Block
bgColor#ccccff
while (moreToDo) {
   SomeType *pst = getNextItem();
   try {
      pst->processItem();
   }
   catch (...) {
      // deal with exception
      delete pst;
      throw;
   }
   delete pst;
}

...

Wiki Markup
\[[Meyers 96|AA. C++ References#Meyers 96]\] Item 9: "Use destructors to prevent resource leaks".

...

RES37-C. Release resources that require paired acquire and release in the object's destructor      08. Memory Management (MEM)      09. Input Output (FIO)RES39-C. Do not use longjmp