Exercise 5 on page 63 of the C++ Primer