example_4.cpp   Complete rewrite of main function