previous | start | next

## Automatic Memory Management

- Consider the following declarations.

  >     Department qc("Qualitiy Control", Employee("Tester, Tina", 50000));
  >     Department dept("Shipping", Employee("Hacker, Harry", 35000));

- Suppose we assign one department to the other.

  >     dept = qc;

- This assignment causes a memory leak! (See following slide).
- When one object goes out of scope (and the other doesn't) the `Employee` is destroyed, causing a dangling pointer.

previous | start | next