Some code of the exercise in C++ Primer