C++ Primer 5th edition exercise