1
2
3//If an exception is raised between allocation and deallocation, memory leak will occur.
4
5void f1() {
6 int* ptr = new int;
7
8 // do something which may throw an exception
9
10 // we never get here if an exception is thrown
11 delete ptr;
12}