...
| Code Block | ||
|---|---|---|
| ||
while (moreToDo) {
SomeType *pst = getNextItem();
try {
pst->processItem>processItem();
}
catch (...) {
// deal with exception
throw;
}
delete pst;
}
|
...
| Code Block | ||
|---|---|---|
| ||
while (moreToDo) {
SomeType *pst = getNextItem();
try {
pst->processItem>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)