Code from McGraw.Hill.Herb.Schildts.C.plus.plus.Programming.Cookbook.Apr.2008