Exercise from C++ Primer: 5th Edition