C++: Add a second example.

This commit is contained in:
Geoffrey White
2024-05-08 11:25:42 +01:00
parent 575b66a054
commit 486226814a
3 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
void g() {
MyTask *task = NULL;
try
{
task = new MyTask;
...
delete task;
task = NULL;
...
} catch (...) {
delete task; // GOOD: harmless if task is NULL
}
}